I may misunderstand the spec of triggers but let me ask the following question.
I m developing an app that creates a spreadsheet with a container bound script to the spreadsheet. The script has functions that expect to be run by triggers (onEdit or so on). Since the functions have some feature that require authorization and simple triggers cannot run them, "installable trigger" should be used. I don't wanna users to set triggers by themselves so I also wanna create trigger by program when a user open the spreadsheet at the fist time using simple trigger function onOpen(e).
My problem is that installable trigger cannot be created in the simple trigger function like below.
function onOpen(e) {
const triggers = ScriptApp.getProjectTriggers()
const trigger = triggers.find(trigger => trigger.getEventType() === ScriptApp.EventType.ON_EDIT)
if (!trigger) {
// ↓error occurs "Exception: ScriptApp.getProjectTriggers を呼び出す権限がありません。"
ScriptApp.newTrigger('myFunction').forSpreadsheet('spreadsheetId').onEdit().create()
}
}
Is there anyway to create installable triggers in simple trigger function ? or Google Script API SDK (node.js) can solve this ?
Thanks,