Reputation: 81
I have few sheets that have functions bound to the spreadsheet. Each spreadsheet has its own functions and uses SpreadsheetApp.getUi to run html service. I would like to initiate function calls in all the sheets from a master spreadsheet project? is it possible? Something like getting a handle to the spreadsheet project and run a script in that project?
Upvotes: 8
Views: 21508
Reputation: 143
using library seems to me is the fastest and simplest way to protect your code. for this you need :
1 spreadsheet or any google doc containing Code - SCRIPT A
1 stand-alone script SCRIPT B that you publish as a library.
in the SCRIPT A code you can call the function of SCRIPT B
function callFunctionOfScriptB(){ LibraryIdentifier.functionNameinScriptB() }
you find LibraryIdentifier when you click on Resources + libraries in the column Identifier of the popup
Upvotes: 5
Reputation: 4034
You have two options:
There are pros and cons of each. Neither is about maintainability really.
The library option will afford code completion whereas the web app option will enable (if you wish) for you to run code asynchronously.
Both have different speed penalties. Library enabled scripts are slower as described in the documentation. Web apps will be slower because of urlfetch
latency.
Library functions will use the runtime allowed for them in the host script, whereas web apps will extend runtime and some quotas.
Documentation:
Upvotes: 6