I am trying to organize my code for a Spreadsheet in several script files. Within the script editor I can create as many *.gs files as I want, but I can't figure out how to access code that would be defined in another script.
Simple Example of what I'd like do achieve:
Code.gs:
function onEdit(){
myFunctionFromLibrary_gs();
}
Library.gs:
function myFunctionFromLibrary_gs(){
Browser.msgBox("hi there");
}
The onEdit() is obviously called by a Trigger. Without modification this will result in a Runtime-Error, stating that
myFunctionFromLibrary_gs TypeError: is not a function, it is undefined.
So how can I make this work, or is this currently not supported?
Thx in advance for your help.
Yes, it's possible.
Reference: Google Documentation - features and limitations
I know this is an old question but I found it looking for a similar task and happened to find the answer during my same search. From the docs at https://developers.google.com/apps-script/guide_libraries#writingLibrary:
While your function does not END in an underscore, it may have special meaning in other places than just this, or the _gs suffix may also have special meaning (particularly given the same filename suffix).
I don't know what the
_gs
suffix means for Google, but without it (see code bellow), the code works.file1.gs:
file2.gs