How to call a function onChange?

I want to make a function is triggered when the formula(!) changes the value in the cell. How to use it correctly? The code below writes an error: you do not Have permission to call function newTrigger at [unknown function](Code:8)
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();

ScriptApp.newTrigger("myonChange")
.forSpreadsheet(sheet)
.onChange()
.create();


myonChange function() {
//code
}
June 10th 19 at 16:13
1 answer
June 10th 19 at 16:15
Solution
You are trying to create a trigger for the sheet, and the need for the spreadsheet.
Need
.forSpreadsheet(ss)
instead
.forSpreadsheet(sheet)
did not help - orion86 commented on June 10th 19 at 16:18
What exactly is the error? The trigger is created? - Glenna29 commented on June 10th 19 at 16:21
, soran, my bad. Yes, it works, thank you) - orion86 commented on June 10th 19 at 16:24

Find more questions by tags Google Apps Script