I have two Apps Script Code.gs and Code2.gs
I would like to import function A in Code2.gs and use it in function B in Code.gs.
Any ideas ?
If both gs are in the same project, its already available. Else read about apps script libraries.
Import is not needed. Put the function-defined-here.gs
before function-used-here.gs
in the list on the left, and call the function. The order DOES matter.
In addition to the answer from @Zig Mandel
If both gs are in the same project, its already available. Else read about apps script libraries.
Files in the same project are executed by order in the list (in the new editor you can change the order) like importing a bunch of javascript with <script>
tag into an HTML. So you will almost ways want the Code.gs
be the last one in the list (the most dependent one). Also, names are irrelevant since all callback functions are added to the namespace, and later being called by the name from manifest file.
Fact: I searched the document about the fact I mentioned and it is not mentioned anywhwere. I myself have decided stop using GAS for this fact, and these reasons.
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