Trigger Not getting executed when a new row is added through AppSheet form

I have created a trigger in appsheet using the following code:
function createTrigger() {
ScriptApp.newTrigger(‘sendWhatsappToClient’)
.forSpreadsheet(ss)
.onFormSubmit()
.create();
// Toast notification.
SpreadsheetApp.getActiveSpreadsheet().toast(“Trigger’s added.”, “Notification”, 5);
}

The trigger is being created but when a new row is added in sheet using appsheet, then the function ‘sendWhatsappToClient’ is not running…

However when it is added through Google form,it is running perfectly…

You may want to consider using a Workflow-Webhook to the Whatsapp API instead, so you can do everything in the AppSheet editor.


But if you do stay with the script method, here’s a great post by @LeventK with a ton of good info on integrating Apps Script.

[How to Integrate Google Apps Script & Trigger with an AppSheet App](https://community.appsheet.com/t/how-to-integrate-google-apps-script-trigger-with-an-appsheet-app/11805) Tips & Tricks ?

1 - INTRODUCTION Dear valuable members of the community, This post is my personal long-time promise to @praveen that I’ll write about nearly a year ago but couldn’t be able to keep my promise and spare some time because of our work load as an AppSheet Partner and Developer. Now I have found some time, I decided to write it down. Hope you can find a benefit of this post for your apps and/or projects. Before starting and diving any deeper, I should admit that this requires at least a beginner…

2 Likes

onEdit triggers do not fire when data is edited and synced to the spreadsheet via AppSheet.

I went thought these files, but on edit trigger runs if anything in sheets is modified. I want to run a trigger only when a new row is added through appsheet, but couldn’t find a solution anywhere. It’ll be great if I can get some help on using webhooks through which only a part of code is run with the event object attached to it.

Here’s a similar use case to yours that you could refer to:

[Create folder structure in Gdrive](https://community.appsheet.com/t/create-folder-structure-in-gdrive/18911) Tips & Tricks ?

It is possible to create a single folder or hierarchical folders in Gdrive to save images under the app folder (see Workflow to create a new folder in drive) However, it may not be sufficient for your needs as you need a different file structure for organizing miscellaneous files of different file types. Here is a bit of google apps script code that may be helpful to create a folder structure. var GDRIVEFOLDERID = “1234567890abcd” function doPost(e) { var json = e.postData.contents; v…

Read the AppSheet help docs for how to pass JSON to the webhook.

@Kaushal_Didwania1
Instead of onEdit(e), you need to use onChange(e) installable trigger to get what you want.

1 Like