Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I was wondering if someone encountered this issue and thought of a workaround that isn't awful.

I have a trigger on Google Spreadsheets that is configured "on edit", and it works fine if the edit occurs manually (or via formula) from within the spreadsheet itself. However if I modify a cell externally from the Sheets API v4, the cell is changed but the function isn't triggered. Am I missing something, or Google simply doesn't support triggering when change comes from "outside"?

EDIT: As per @TheMaster's suggestion, I wrote:

function test_on_change(e){
  console.log("Changed");
  console.log(SpreadsheetApp.getActiveRange().getA1Notation());
}

The e object is json of the enum that is described here.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
876 views
Welcome To Ask or Share your Answers For Others

1 Answer

As you can read in the Trigger Restrictions:

Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.

In case you want to deploy the script as a Web App as Tanaike mentioned, you might want to check the documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...