Error creating a new object


I'm relatively new when it comes to programming in google apps script and JavaScript.

The fact is that I need to create an object in the following way:

  • Fill in the information fields

  • Press the create button

  • Press the confirm creation button


    I am interested in the fact that the object in question is created in the third step and not before and to achieve this I use the following code:

      var dialog=app.popups.ConfirmationDialogType;
        widget.datasource.createItem(function(newRecord) {
        // Callback is called after the record is saved, so it now has a key.
        var key = newRecord._key;
      app.popups.EmptyFields.visible= true;

    The problem comes when I try to preview my application, when carrying out these actions for the first time nothing happens. Basically the program does not execute line number 5 of my code, that is, widget.datasource ... I've checked it with sneaks and so on. To make matters worse, sometimes works from the second execution and sometimes nothing at all.

    Does anyone know what can be wrong? Or even better, what is the solution.

    Thank you very much.

    PS: This is my first post, if something else was needed please ask me.

    asked by Pau 08.11.2018 в 16:55

    0 answers