0

I created an installable trigger in a standalone script. When I change something in the target spreadsheet, nothing happens. I don't get to a brekpoint in onEdit. So how do I set up the trigger and onEdit to detect Edits?

ScriptApp.newTrigger('myOnEdit'){
  .forSpreadsheet('1wfcYwChzLmbqxoXoSZUrXgZJIVbtEyNUIpfxmJihAcY')
  .onEdit()
  .create();
)

function onEdit(e){
  // Set a comment on the edited cell to indicate when it was changed.
  var range = e.range;
  var ct = e.changeType
  var ov=e.oldValue
  var nv =e.value
  var sc=e.triggerUid
  range.setNote('Last modified: ' + new Date());
}
ziganotschka
  • 25,866
  • 2
  • 16
  • 33
Steven Greenbaum
  • 311
  • 4
  • 17
  • Does this answer your question? [How can I test a trigger function in GAS?](https://stackoverflow.com/questions/16089041/how-can-i-test-a-trigger-function-in-gas) – TheMaster Jul 29 '20 at 16:50
  • What procedure are you using to test the trigger? Also, as @Rubén mentions, the name of the handler function in the trigger does not exist in your script. You should edit the question if it does. – Aerials Jul 30 '20 at 08:02

1 Answers1

1

onEdit is a reserved function name to be used for on edit simple trigger. It should not be used for functions that will be called by an installable triggers as this could cause undesired effects as executing the function twice by a single event.

The installable trigger is being created to call a function named myOnEdit. In order to make it works your script should have a function named myOnEdit.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Thank you for your response. It is helpful. I tried that but breakpoint still not reached in myOnEdit when I change a cell in the target spreadsheet – Steven Greenbaum Jul 29 '20 at 16:04
  • @StevenGreenbaum Please checkout [How can I test a trigger function in GAS?](https://stackoverflow.com/q/16089041/1595451) – Rubén Jul 29 '20 at 16:22