Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run google app script function from another project

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?

like image 207
hari ts Avatar asked Feb 08 '15 05:02

hari ts


1 Answers

You have two options:

  1. Publish your scripts as libraries and subscribe to each in each other of your script projects.
  2. Publish your scripts as web apps with specific functions as individual pseudo webhooks. Sort of like a distributed API.

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:

  1. Publish your scripts as a library
  2. Running apps script as an endpoint
like image 93
JSDBroughton Avatar answered Sep 28 '22 11:09

JSDBroughton