5

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.

Community
  • 1
  • 1
wils484
  • 275
  • 1
  • 3
  • 14

2 Answers2

7

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)

Serge insas
  • 45,904
  • 7
  • 105
  • 131
1

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

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36