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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With