1
votes

A google script runs but times out during a .getrange(""). Was running a couple of hours prior. Google apps in general slowed down so we needed to restart the routers. The problem appears to have come after.

All google script functions were working a couple of hours before, no changes to the code were done and no structure changes to the spreadsheet were done as well.

Google sheet running google script on chrome.
Deleted Cache and cookies.
Removed offline sync.
Created a copy of the spreadsheet with the script, none of the functions would run.
Created a copy from history (current version history so a duplicate of the current sheet) and the functions run
I've tried recreating the range on the on the spreadsheet, tried addressing the range using A1Notation and still nothing.

function DraftEmail(){
var selectedRow = SpreadsheetApp.getActiveSheet().getActiveRange().getRowIndex();
var clientName = SpreadsheetApp.getActiveSheet().getRange("EmailCouplesName").getCell(selectedRow, 1).getValue();  

And my execution log:

[19-05-14 08:40:28:770 PDT] Starting execution
[19-05-14 08:40:28:776 PDT] SpreadsheetApp.getActiveSheet() [0 seconds]
[19-05-14 08:40:28:776 PDT] Sheet.getActiveRange() [0 seconds]
[19-05-14 08:40:28:777 PDT] Range.getRowIndex() [0 seconds]
[19-05-14 08:40:28:777 PDT] SpreadsheetApp.getActiveSheet() [0 seconds]
[19-05-14 08:46:41:681 PDT] Sheet.getRange([EmailCouplesName]) [372.903 seconds]
[19-05-14 08:46:41:782 PDT] Execution failed: Exceeded maximum execution time [372.906 seconds total runtime]

So it gets stuck at the .getrange()

1
I don't think there's a documented sheet.getRange(NamedRange String) methodTheMaster
@TheMaster Perhaps it's an A1Notation StringCooper
@Cooper How? See getRange("EmailCouplesName"). There's no digit anywhere there.TheMaster
The "EmailCouplesName" is a Named Range in the Sheet Schedule.Glimmer Films

1 Answers

0
votes

If you use named range, then you should call getRangeByName on spreadsheet.

function DraftEmail(){
var selectedRow = SpreadsheetApp.getActiveSheet().getActiveRange().getRowIndex();
var clientName = SpreadsheetApp.getActive().getRangeByName("EmailCouplesName").getCell(selectedRow, 1).getValue();  

Make sure you don't have multiple ranges with the same name.