Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Scripts in 1 project, App Script

I have an App script project with several html files and 2 scripts(Code.gs, Utilities.gs). I want to be able to call functions from Utilities.gs in Code.gs but I dont know how to communicate between 2 scripts in one project. Is there a way to import/include scripts or something similar?

For example if I have a function called getInfo() in Utilities.gs I would like to call getInfo() in Code.gs. In java this would be Utilities.getInfo()

I dont see anything about this in the docs.

like image 803
nupac Avatar asked Jul 23 '14 10:07

nupac


People also ask

Can you have multiple scripts in Google Sheets?

Within a script project, you can have multiple script file. For example, if you have three different things that you want to automate in Google Sheets and you create three different scripts for it, you can have all the three different scripts in the same Project file.

How do you concatenate in an app script?

Concatenating strings To concatenate two strings (i.e., to join them together), use the concatenation operator ( + ). Both the concatenation operator and the addition operator have the same symbol + but Apps Script will figure out which operation to perform based on the values being operated on.

How do you add a script to a project?

To add a new script to the project, right click on the project name and select Add New to Project from the context menu. With a new script project established, add a new script to the project. Use File » Save Project As to save the project as the desired name.

How do I embed a script in Google Apps?

Navigate to the page in your Site where you want to embed the web app. Click the edit icon, and then Insert > Google Apps Script. Choose the script from the list that represents your web app. If your web app is not bound to this Site, you can paste in the web app URL instead.


1 Answers

You don't need to do anything, every function in every script files in the same project are accessible from any script file... the separation in script files is only a comfortable way to store things the way you want. The project is the only "real" container.

like image 151
Serge insas Avatar answered Sep 24 '22 17:09

Serge insas