google-apps-scriptgoogle-sheetstriggersauthorizationurlfetch

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.


Solution

  • 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 explained in the documentation and discussed in this Google Apps Script community thread.

    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...)