Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some methods/functions simply do not work in onEdit trigger

I'm looking to call UrlFetchApp.fetch() based on user input on a sheet but nothing happens. No errors, just silently ignores the call. Same goes for MailApp.sendEmail() and GmailApp.sendEmail()

This is on a Google Apps domain, and only domain users are using the Google Sheet.

like image 604
belteshazzar Avatar asked Jun 29 '15 09:06

belteshazzar


People also ask

How do you trigger an onEdit in Google Sheets?

The onEdit(e) trigger runs automatically when a user changes the value of any cell in a spreadsheet.

How do I enable triggers in Google Sheets?

Under Run, select the name of function you want to trigger. Under Events, select either Time-driven or the Google App that the script is bound to (for example, From spreadsheet). Select and configure the type of trigger you want to create (for example, an Hour timer that runs Every hour or an On open trigger).

How do I debug a Google script onEdit?

The only way you can debug an event object is to print the value of e after an event was made. You can view each event by clicking the Executions tab of your Apps Script.


1 Answers

Simple triggers like onOpen or onEdit are not able to do anything that requires authorization like sending mails because they run silently and anonymously. This is all explained in the documentation .

You should simply rename your onEdit function to something else - SpecialOnEdit for example ? - and create an installable trigger (documentation) from the script editor menu (ressources/triggers/create a new trigger...)

like image 153
Serge insas Avatar answered Oct 24 '22 23:10

Serge insas