How to run scripts in Behavior

Hello.
I want to run Apps Script when I click the button after adding the button in Behavior.
I did it like this.
1. Behavior
  1) New Action
  2) For a record of this table : Data Event Cache Table
  3) Do this : Data: set the values of some columns in this row
  4) Set these columns : Column, Value Add
2. Automation
  1) New Bot
  2) New Event
    . Event Type : Data Change, All changes
    . Table : Data Event Cache Table
  3) Processes : Run a task
  4) Tasks : Call a script

Click the button you added in the Behavior to modify the data in the Data Event Cache Table.
Detects the event on the Bot and executes the script on Tasks.
However, you must wait a few seconds for the data to be modified.
What I want is for the script to run as soon as I click the button on the Behovior.
It would be best if there is a Call Script feature in the Do thisis of Behavior, but I would like to ask if there is another way to run the script immediately.

Solved Solved
0 4 847
1 ACCEPTED SOLUTION

To clarify, your issue is just that it takes a few seconds for the script to run? No, there's not really any way around that. You can execute a GAS from Appsheet in at least 3 different ways now:

  1. onChange trigger on the spreadsheet for the GAS. 
  2. Webhook to a web-deployed GAS
  3. The new "call a script" Automation

All 3 ways require some data change to happen. The first one requires the data to be completely synced to the sheet, but the second 2 should be reliably quicker as the Bots should execute as soon as the change happens on the app.

------------------

...Actually, while writing this, I've just thought of another way you could potentially execute a script, without requiring any data change, and possibly faster. If you web-deploy your script, and include an appropriate doGet() function, you can use the Appsheet Action "external open a webpage" to trigger the scripts doGet(). Of course that requires the user to, at least briefly, navigate out of the app to a webpage on their browser. But it might just be slightly faster. Worth the extra effort though?

View solution in original post

4 REPLIES 4

To clarify, your issue is just that it takes a few seconds for the script to run? No, there's not really any way around that. You can execute a GAS from Appsheet in at least 3 different ways now:

  1. onChange trigger on the spreadsheet for the GAS. 
  2. Webhook to a web-deployed GAS
  3. The new "call a script" Automation

All 3 ways require some data change to happen. The first one requires the data to be completely synced to the sheet, but the second 2 should be reliably quicker as the Bots should execute as soon as the change happens on the app.

------------------

...Actually, while writing this, I've just thought of another way you could potentially execute a script, without requiring any data change, and possibly faster. If you web-deploy your script, and include an appropriate doGet() function, you can use the Appsheet Action "external open a webpage" to trigger the scripts doGet(). Of course that requires the user to, at least briefly, navigate out of the app to a webpage on their browser. But it might just be slightly faster. Worth the extra effort though?

Hello,

@Marc_Dillon could you explain this last option doGet?

thanks

I'm not sure what more explanation you're looking forward beyond what I already said.

I would find a way to send an email cliclking on a button without write/update field app, but only calling a script and I hope your solution could be a better solution.

could you suggest me a way?

Top Labels in this Space