1
votes

I've read all the documentation on Installable Triggers and questions here on StackOverflow, but the triggers simply do not run based on the installer's permissions. They run based on the permissions of whoever makes the modification in the spreadsheet thus triggering grab_info.

According to the documentation: They run as the user who installed the trigger, not as the user triggering the event.

So I've been manually deleting the triggers, reloading, running the trigger creator below, and then reloading the spreadsheet. While still logged in the trigger works fine, then after I log out, the trigger doesn't work. It's functioning under the current user, not the installer.

Am I doing something wrong?

Here's my trigger creation code below:

function add_trigger() {

  ScriptApp.newTrigger('grab_info').forSpreadsheet(SpreadsheetApp.openById('blahblah')).onEdit().create();

}

Edit:

This is the code that is currently failing:

  function grab_info(){
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    var i = sheet.getActiveCell().getRow();
    var date = ss.getRange("C" + i);
    var due_date = 'test';
    date.setValue(due_date);
  }
2
I see no reason why your trigger would stop working when you're not logged in. And it will continue to run under the authority of the person who created the trigger (using your function). The rule applies to the installable trigger no matter how it is created, manually or by a function.Serge insas
Yeah, it's pretty frustrating. I was trying to show this to my boss in a meeting and all the triggers were broken for him >_<Ryan Ward

2 Answers

2
votes

From the same documentation you quoted:

The installable triggers have some similarities to simple triggers, but also these differences:

They may not be able to determine which user triggered the event being handled. For clock tick events, this is not important, but in a Spreadsheet edit event, the user changing the Spreadsheet would not necessarily be identifiable.

So, depending on what's in your script and what privileges are required, it may be failing because the user can't be identified. Change your notification settings to get immediate feedback, as the resulting email should tell you more.

1
votes

I've had the same experience as you Cayetano. Installable triggers do NOT run as the documentation claims with the permissions of the (trigger) installer. Google have known this was a bug since March 2012, acknowledged in an email to me by Anton Soradoi who was at the time a member of the GAS team:

"The issue you are running into appears to be a bug. We are currently investigating it. I will get back to you with more info once I have it."

If you haven't already, please star this issue that was raised on the Issue Tracker about it.

Thanks for your question because it led me to a potential workaround suggested by Serge Insas here (see Edit 3 in his answer) that I haven't yet tried but seems like a great idea. Fingers crossed!