Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a call from one Google Apps Script to a function in another?

Is there an easy way of making a call from one Google Apps script to a function in another?

I'm writing two scripts, one which should use functions from the other. I want the two to have different sharing permissions, however, so I don't want to put them in the same project.

I can't seem to find any "require Xxx.gs" type function in the documentation.

I found this: Call functions from another "class" / file

But I get "xxx function not found" errors if I try to call a function from a different file.

like image 725
wils484 Avatar asked Oct 09 '13 22:10

wils484


2 Answers

As Corey mentioned in the post you refer to you need to use libraries to do what you want. You can not use functions from another project in a project (but you can of course use any function from different script files inside a project)

like image 168
Serge insas Avatar answered Oct 18 '22 19:10

Serge insas


Besides libraries, if you actually want to keep the projects separate you can publish a service url and use parameters to call it from the other script with urlFetch, as in myserviceurl?call=myfunction&param1=x

like image 1
Zig Mandel Avatar answered Oct 18 '22 18:10

Zig Mandel