Status Update
Comments
da...@gmail.com <da...@gmail.com> #2
There appears to be a bug of some kind when using SpreadsheetApp WITH triggers. See this error here...
https://code.google.com/p/google-apps-script-issues/issues/detail?id=4033
In my case the error was with the "On Change" trigger and yours is with the "On Open" trigger. This issue does not seem to occur with the "onEdit" trigger though. Google can you please look at this? wchiqu...@gmail.com I will "star" your post and please do the same to mine. We need to get google on this one.
In my case the error was with the "On Change" trigger and yours is with the "On Open" trigger. This issue does not seem to occur with the "onEdit" trigger though. Google can you please look at this? wchiqu...@gmail.com I will "star" your post and please do the same to mine. We need to get google on this one.
ba...@gmail.com <ba...@gmail.com> #3
Unfortunately specifications was changed. Methods that related to activate no longer have any effect if they are called from an onOpen or onEdit trigger.
You can get more details about change below.
Google Apps Script
Issue 36761148 : April 22, 2014
New Spreadsheet: activate() doesn't change active sheet into onOpen service function event
https://code.google.com/p/google-apps-script-issues/issues/detail?id=3928
Release Notes
April 17, 2014
The Document method setSelection the Sheet method activate, and the Spreadsheet methods setActiveRange and setActiveSelection no longer have any effect if they are called from an onOpen or onEdit trigger.
https://developers.google.com/apps-script/releases/#april_2014
bakcy0175
You can get more details about change below.
Google Apps Script
New Spreadsheet: activate() doesn't change active sheet into onOpen service function event
Release Notes
April 17, 2014
The Document method setSelection the Sheet method activate, and the Spreadsheet methods setActiveRange and setActiveSelection no longer have any effect if they are called from an onOpen or onEdit trigger.
bakcy0175
Description
With new Google Sheets:
The setActiveSheet method does not set the focus on the sheet (at the interface) when run from a trigger onOpen (Simple or Installable). If we run the onOpen from the code editor works correctly.
Please provide a small sample script that reliably reproduces the issue.
The sample should run as-is or with minimal setup, without external
dependencies.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.insertSheet();
ss.setActiveSheet(sheet);
}
What steps will reproduce the problem?
1. Create a new spreadsheet.
2. Insert the code.
3. Close and open the spreadsheet.
What is the expected output? What do you see instead?
Expected output is the newly inserted sheet is active.
I see the first active and not the new sheet.
Please provide any additional information below.
This happens with the new version of Google Sheets, executing the same code with the old version of Google Sheets works as I expect, however, two sheets are inserted instead of one. For correct operation in the old version must be made via an Installable Trigger.