Google App Maker: Add a field with the current date/time - google-app-maker

new to app maker (and ready to fall in love)
I want every new row to have a field with the date+time that the row was created at. How can I do that?
If you'd like to base your answer on existing code, please base it on the project-list example
Thanks!

Add a new field to the Data model (e.g. Projects) called, say DateCreated, of type Date.
In the onCreate event of the Data Model ('Projects'), add the line:
record.DateCreated = new Date();
To check your work, add the DateCreated field to the Main page by copying the DueDate field and changing the data binding name to DateCreated.

Related

GSuite Appmaker - how to set default value in table using button

I am trying to put together a mock up for a data collection app for a local nonprofit using GSuite's AppMaker. So far I really like the tool.
One thing I need to be able to do is streamline the data entry for the site representatives. In my app, I display a list of students in a table, where one of the columns is a boolean value which represents attendance. The desired result is for the teachers to be able to input the date field one time using the date input button at the bottom of the page. Then they can quickly point and click down the Present column to log attendance.
My question is: how would I link the date selector dropdown so that the date field pre-populates with the selected date from the input field? I don't want them to have to enter the field over an over again since its the same for each row and I don't want the user experience to feel clunky.
Screenshot of the App for reference:
Using client script, you can add the following to the onValueEdit event handler of the date widget at the bottom.
var items = widget.root.descendants.<YourTable>.datasource.items;
items.forEach(function(item){
item.<DateField> = newValue;
});
The only thing to take into account is that when using client scripting, you will only update the records loaded in the table at the moment; i.e, if your table has paging, it will only update the current page. If you are using paging, then you will need to add the following code to the onPreviousClick and the onNextClick event handlers of the pager widget:
var selectedDate = widget.root.descendants.<YourDatePicker>.value;
var items = widget.root.descendants.<YourTable>.datasource.items;
items.forEach(function(item){
item.<DateField> = selectedDate;
});

Powerapps - get stuck with UpdateContext

I am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?

Action_dt fields purpose in PS_POSITION_DATA in peoplesoft

What is the purpose Action_dt in PS_position_data table?
What exactly is this field say here?
This field indicates the date that the action was performed (like add a new row), it is not the effdt, which can be different from the action dt.

How to makes datasource truly unchangable?

I have datasource on a form created by code.
formBuildDataSource = form.addDataSource("My_table");
than I open a detail which has datasource from same table and dynamic link and same data row. When I change something od detail and than run
getFirstSelection(formCaller.dataSource(1));
I do not get old data but the new modified data. Is there a way how to get old data from base form before this modification? Somehowmake data datasource on old form unchangable (for whole existence of form).
When I set
formBuildDataSource.autoQuery(false);
formBuildDataSource.autoSearch(false);
than I see no data on a first form. So it would be nice to do something like:
formBuildDataSource.getData();
formBuildDataSource.autoQuery(false);
formBuildDataSource.autoSearch(false);
The Args.record(...) is used for something else so it would be nice to do not need to use it.
I am using AX 2012.
It isn't very clear what you are trying to achieve. If, after modifying a record, you want to check what values its fields had before the change ("Is there a way how to get old data from base form before this modification"), you could have made a copy of the original record before making the changes, e.g.
MyTable myTableOrig = myTable.data();
or if you don't need system fields then
MyTable myTableOrig;
buf2Buf(myTable, myTableOrig);
After that you can always compare current myTable field values and original field values copied to myTableOrig.

Synchronization between AOT and DB - Will I lose data?

I am new to AX 2009. I am adding a new field to the Tax 1099 tab for vendors to store additional info. I created a new extended type that is a 9 char. string. When I create a new string field on the VendTable the default length is 10. I then change it to use my extended type (9 chars in length). When I try to save the changes I get the text that says "...could result in data truncation". I know that is fine because this is a new field and there is no data in the db yet.
BUT - I also get the message "The action you have taken will drop and re-create the table VENDTABLE and all associated index. This can be caused by renaming a field or changing the type and/or size of the field."
It's unclear to me if it is ok for me to continue. If I continue will I loose all the data in my VENDTABLE or will the data be re-created along with the table?
I've read the information here but I'm still unsure if I will loose my VENDTABLE data or not if I continue.
The system will create a new table with the new field size, copy all the data from vendtable to the new table (truncating data in your 1099 field), then delete vendtable and rename the new table to vendtable.

Resources