My company has been trying to move our processes online using G Suite. For some reason, the GAS wouldn't allow me to set up a trigger programmably and returns an "Exception: Action not allowed". See below screenshots 1-3.
[Asking for authorization][1] //SO doesn't allow me to post more than two links, this is a screenshot that tells you the script needs authorization and asks you to select an account.
Simplest code:
function myFunction() {
Logger.log("Trigger created");
}
function createTrigger(){
ScriptApp.newTrigger("myFunction")
.forSpreadsheet(SpreadsheetApp.getActive())
.onEdit()
.create();//this line wouldn't be executed
}
The observation/tries I had so far are:
- This only happens in files(standalone and bound scripts) stored in Team Drive, works well in My Drive
- I can go to Edit -> Current Project's Triggers and manually set up an On edit trigger
- I'm guessing it has something to do with domain authorization but couldn't find any useful information
- I had a chat with Google Cloud Support but had no luck. Part of their response:
Thank you for contacting G Suite Support. I understand that you are experiencing an issue with Scripts that is not part of the core suite of G Suite services defined at gsuite.google.com/terms/user_features.h.t.m.l.
The issue you’ve experienced is currently outside the scope of our support offering and we won’t be able to offer you further direct assistance at this time.
Since this happens in team drive, I'm not able to provide a link to the file.
Any help will be appreciated.
Thanks in advance!
Team Drive files are "owned" by the team and cannot be authorized by a single user. I've not found new documentation on how to mitigate this problem which is why we still manage team-based scripts in shared Google Drive folders.