Reputation: 109
In App maker we enabled the manual save mode. On button click a new form will open and we will create an empty record, when user fills the fields and clicks the save button saveChanges function will save all the values.
In documentation and sample projects I can see after a record creation _key value is updated in the data source and we can use that key value to query record from its child model.
But in our case key value is not returned. But after save changes function when we open that record key value is coming, what could be the issue.
Upvotes: 1
Views: 807
Reputation: 6347
You don't have record key on the client, until you save it, since record key is generated by the server. This applies both to Auto and Manual save modes.
Here is code snippet from App Maker documentation:
var myCreateDatasource = app.datasources.MyDatasource.modes.create;
var draft = myCreateDatasource.item;
draft.Name = "Name";
draft.Age = 21;
// Create the new item
myCreateDatasource.createItem(function(newRecord) {
// Callback is called after the record is saved, so it now has a key.
var key = newRecord._key;
// Do something with the key here.
}
Upvotes: 2