Reputation: 7769
Where the Code.gs file is bound to the spreadsheet, user-defined functions are stored there along with any other functions like event handlers.
In a standalone project, would Code.gs hold user-defined functions or is there some other mechanism which makes functions defined in a standalone project visible to the spreadsheet that uses it?
Upvotes: 0
Views: 80
Reputation: 201378
If my understanding is correct, unfortunately, the function in the standalone script cannot be directly used as the custom function for Spreadsheet. So as a workaround, how about using the standalone script as a library? Please think of this as just one of several answers.
The sample situation is as follows.
Standalone script has a function of myFunction()
. This is used as a library. The sample library name is "SampleLib". The sample script is as follows.
function myFunction(e) {
return "Done: " + e;
}
Container-bound script of Spreadsheet has a function of CustomFunction()
. The sample script is as follows. Before you use this script, please install above library.
function CustomFunction(e) {
return SampleLib.myFunction(e);
}
=CustomFunction("sample")
is put in a cell, Done: sample
is returned. By this, it is found that myFunction()
of the library of "SampleLib" is used.If this workaround was not the result you want, I apologize.
Upvotes: 1