Gas does not work when Google spreadsheet starts as a trigger (for example, onOpen()).

Asked 1 years ago, Updated 1 years ago, 38 views


when Google spreadsheet is started (when spreadsheet is opened) I'd like to run the gas I created in the script editor.
Either of the following methods will not work at startup:

On the script editor,
in the code .gs (default) script file Write the following code and
If you do it individually, you can see that it works.

function test(){
    Browser.msgBox("Hello!");
}

Close the Script Editor and Spreadsheet

when re-opening the spreadsheet The message box should say "Hello!" but it doesn't.

I can't help it, so I'll delete the above trigger configuration
Rewrite the "test" function itself to "onOpen" as follows

function onOpen(){
    Browser.msgBox("Hello!");
}

Close the script editor and spreadsheet in this state

when re-opening the spreadsheet "Hello!" should be displayed in the message box.
There was still no message.

I think I'm following the proper procedure for both of them.
Is there a mistake somewhere?
(By the way, the account environment is for paid G suite users.)

If you have any idea of this phenomenon, please let me know.

google-apps-script

2022-09-30 15:39

1 Answers

When I tried the code in my environment, both 1.2. worked.
There seems to be no particular problem.

To check where the problem is

  • Check Logger.log("hello!"; to see if the function itself is started
  • check for exceptions in try {Browser.msgBox("hello!");}catch(e){Logger.log(e);}
  • Try recreating the spreadsheet itself

Why don't you check it like this?


2022-09-30 15:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.