I've searched around and still can't find anything directly related to the failure message I'm receiving. The script hasn't changed and it used to run just fine, but now in the past week or so it's failing more and more often. There are only 3 triggers on this file onOpen, onEdit(e) and the installed trigger that calls the percentChange function once a day in the morning. It's super simple, it grabs 2 named ranges, one is a column of percentages and the other contains the length of that data and then copies the percentages to another column so that we can track the daily percentage difference.
Here is the code(link to a bare spreadsheet):
function percentChange() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Overview Status');
var calcPercentRangeObject = ss.getRange('calcPerc');
var calcPercentRow = calcPercentRangeObject.getRow()+2;
var calcPercentColumn = calcPercentRangeObject.getColumn();
var dataRangeObject = ss.getRange('numCabs');
var dataRow = dataRangeObject.getRow()+2;
var dataColumn = dataRangeObject.getColumn();
var dataLength = dataRangeObject.getValue();
var currentPercent = ss.getRange(calcPercentRow, calcPercentColumn, dataLength, 1).getValues();
ss.getRange(dataRow, dataColumn, dataLength, 1).setValues(currentPercent);
}
Should I add a delay? That seems like a "janky" workaround...
Another question: why does this code take 10+seconds to run from the trigger but generally takes less than a second to run from the script editor?
Edit: It's not really a correct fix but I put in a 400ms delay after line 6 and have only gotten the error message once more...what an odd work around...
This stopped working, I tried multiple delays spread out and removing the delay altogether. I still don't understand why it's intermittent without the code changing?!?!
I am the owner. It's shared with less than 60 people I created the trigger manually The only other installable trigger is onEdit() The script is set to run when no-one would really be looking at it a couple hours before the shift would start.
percentChange Time-Driven triggered at the same time
. It's very likely that you script has several time-driven triggers, if so, delete all of them. In order to help you to find what caused the problem add more details about you are creating the time-driven trigger. If you think that this is a Google issue, raise an issue report through the Google Apps Script issue tracker.