Google App maker record key value

南笙酒味 提交于 2019-12-11 05:30:05

问题


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.


回答1:


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.
 }


来源:https://stackoverflow.com/questions/46067509/google-app-maker-record-key-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!