Reputation: 1
function TEST() {
var test = 10;
return test;
}
Any thoughts on this?
Upvotes: 0
Views: 542
Reputation: 38435
At runtime Google Apps Script, loads all the files before actually running the invoked function, automatically assigning an authorization mode. When running a custom function the authorization mode is "CUSTOM_FUNCTION" that impose several limitations. Because of this:
On projects having custom functions (and also when having simple triggers), avoid calling any method that requires authorization on the global scope. As a general rule of thumb for people starting with Google Apps Script, avoid making variable declarations using Google Apps Script methods. It's safe to assign literals primitives (i.e. numbers, strings, etc.) and object literals.
Avoid calling functions in the global scope, i.e. avoid writing myFunction()
and (() => something )()
.
When creating a "mcve" start from scratch, meaning create a new spreadsheet, create the bound project, then only add the custom function code. If necessary add the other code lines starting by the global variables.
NOTE: Bound projects are some sort of "light" editor add-on. If you will be working complex bound projects, checkout the Editor add-on documentation, like the article "Editor add-on authorization" (link included in the references section). The main functional difference with "full" editor add-ons is that the bound project simple triggers only works with the bounded document.
References
Upvotes: 0
Reputation: 50890
The error says
No such user (line 0).
Notice that the error is on line 0. It means the function you're showing in your question is NOT the problem. The problem is because of other code in other files, which are invoked before running this function. Common culprits are
Upvotes: 1