Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...