Error creating a new object

0

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:

    if(widget.parent.parent.descendants.Field.value){
      var dialog=app.popups.ConfirmationDialogType;
    
      dialog.descendants.ConfirmButton.getElement().onclick=function(){
        widget.datasource.createItem(function(newRecord) {
        // Callback is called after the record is saved, so it now has a key.
        var key = newRecord._key;
        tipus(key);
        });
    
        dialog.visible=false;
        app.showDialog(app.pageFragments.CreatedType);
    
      };
    
      console.log("1");
      app.popups.ConfirmationDialogType.visible=true;
    
    }else{
      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
    source

    0 answers