To copy the AppSheet Apps Script Examples project:
-
Open the AppSheet Apps Script Examples project:
Open Project - Click Copy
to make a copy of the project.
This copies the project to the root folder in My Drive by default. -
Rename the project to AppSheet Apps Script Example (or a name of your choosing).
You'll call thesayHello()
function that is defined in this project from your AppSheet app to log a message to the Apps Script execution log:
function sayHello(msg) {
Logger.log('AppSheet says ' + msg);
}
For more information about this project, see Use the AppSheet Apps Script Examples Project .
To call the Apps Script from an automation:
- Make a copy of the Shirt Orders Example
spreadsheet.
Click Make a copy to download and open a copy of the spreadsheet in Google Sheets. - Rename the spreadsheet, if desired. For example, to: Shirt Orders.
- Sign in to AppSheet .
- On the My apps page, click Create > App > Start with existing data
.
The Create a new app dialog displays. - Optionally, edit the app name and select a category.
- Click Choose your data
- Click Google Sheets to access your Google Drive.
- Navigate to and select the Shirt Orders spreadsheet that you copied in Step 1.
- Click Select
.
AppSheet sets up your app. - Click Customize your app to open the app in the AppSheet editor.
- Click Automation
and click +in the Bots heading. We've made some improvements to the app editor .
You are opted in to the new editorby default, but you can switch back to the legacy editor at any time.If you are using the legacy editor
Click Automation > Bots and click + New Bot - Select the following item in the list of suggestions:
When a Shirt Orders record is created or updated, send a notification - Click the Send a notification step to edit it.
-
Change the name to Call a script .
-
Under Task Settings in the right pane, change the task type to Call a script .
-
In the Apps Script Project field:
-
Click Browse (File icon).
-
Navigate to and select the AppSheet Apps Script Examples project in your Drive.
-
Click Select .
-
If prompted to authorize, click Authorize and follow the prompts.
Note : You'll only need to authorize the first time you access the project.
The Apps Script Project is added and the Function Name field is populated with a drop-down list of available functions from the project
-
-
Select sayHello(msg) from the Function Name drop-down.
The Function Parameters field is displayed.
-
For the msg argument, enter the following expression using Expression Assistant:
'Hello from AppSheet' -
Click Save to save the app.
-
In the right pane, click the mobile or tablet icon to display the app emulator.
-
Add a new shirt order and click Save .
-
Click Sync to sync your changes.
To confirm the execution of Apps Script:
-
Return to the Apps Script home page and view the AppSheet Apps Script Examples project.
-
Click Executions in the left navigation bar to confirm that sayHello() function was successfully completed. You may have to click Refresh if the log has not appeared.