3

I want to create a simple time trigger to my sheet using Google Script, I do all like described in docs, but when I call function I getting error:

Google Apps: You do not have permission to call newTrigger

I try to find solution in Internet but didn't get any results. Can somebody help me? Thanks!

P.S. My code:

 ScriptApp.newTrigger("consolius")
   .timeBased()
   .everyMinutes(1)
   .create();

function consolius() {
   SpreadsheetApp.getUi().alert('Hello, world!');
}
2
  • Post the code generating the Trigger. Have you read all the limitations? developers.google.com/apps-script/guides/triggers/… Commented Jul 3, 2015 at 12:23
  • @Kriggs, so how I get from this Time-driven triggers cannot run more frequently than once per hour. when I do this ScriptApp.newTrigger("consolius").timeBased().everyMinutes(1).create();`, so I cant do this? but exists method for run code every minute? Commented Jul 3, 2015 at 12:28

1 Answer 1

2

The restrictions mentioned in comments do not apply to your use case, they are for add-ons only. The right info is here.

But even if you actually can create a timer trigger to run a function every minute you can not use the method you try because a timer trigger can't interact with the Ui.

If you look at the error notification you'll see that message :

Details:
Start   Function            Error Message                                            Trigger    End
7/3/15 4:08 PM  consolius   Cannot call SpreadsheetApp.getUi() from this context. (line 26, file "clean sheet") time-based  7/3/15 4:08 PM

Another point of interest : you should include the script that creates the trigger in a function otherwise you will create a new trigger every time you run ANY other function in that project, including the function that the triggers calls, this will rapidly become quite messy ! (everything that is "global" is executed each time any function is called).

Last but not least : you can't use such code in a custom function, it has to be in a script you run from a menu or a button.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.