Automated Email Trigger for Two-Step Approval Process in google sheet

29 Views Asked by At

We have a two-step approval form, where approval from both approver 1 and approver 2 triggers the drafting of an email to the IT department. However, this should only occur when the status is changed to "approved." To address this, I created a code in Google Sheets that functions only when the status is changed to "approved" or when the status is edited from "pending" to "approved," prompting an email to be sent to the IT person. Unfortunately, the "onEdit" function is not activated in situations where the status is changed from "pending" to "approved" programmatically, as the "onEdit" trigger in Google Apps Script only activates when a user manually edits a cell in the spreadsheet.

1

There are 1 best solutions below

0
Boris Baublys On

Try using batchUpdate() and USER_ENTERED instead of setValue(). You will need to enable the Sheets API. There is an example here.