Search code examples
google-app-maker

How do you capture the id of a record when it is created?


So I have a script, that among other things, does this:

widget.datasource.createItem();

How do I capture the ID of the item?


Solution

  • I just tried using the link provided by @Morfinismo and it worked. Try with

    datasource.createItem(function(record) {
    
    var key = record._key;
    
         alert("Created new record. Id: " + key);
    
       });
    

    here https://developers.google.com/appmaker/scripting/api/client#Record you will find the information about the property "._key" which will be the id in this case for your question.