Is there a way to run a google app script from a different app script?
im just getting into google app scripts and i couldnt find anything on the internet
It seems like you are looking for libraries functionality in Google App Script. Documentation
You can save a version of the script that you have the functions in it, and import the functions on to a second script file through menu>resources>libraries. You need to use script id for importing libraries, which you can find from menu>File>Project properties>Script ID
You can then execute the function using the script file name as the reference.
You can use the Apps Script API, you may find this helpful Executing Functions using the Apps Script API
"The Apps Script API provides a scripts.run method that remotely executes a specified Apps Script function"
You can call google app script form javascript or web page.
You have to implement doGet(or post) and publish your google app script.
I found good example.
Cheers.
Related
I'm trying to find a way to run Google App Script code that's hosted on GHE. I found somewhere that you could get the script as a text string and use eval() to execute it as code, however I've read that it's a very unsecure way to do it and it shouldn't be done. Does anyone know any alternatives ways to run hosted code on Google App Script?
You could:
use this extension: https://chrome.google.com/webstore/detail/google-apps-script-github/lfjcgcmkmjjlieihflfhjopckgpelofo
use git and clasp CLI to push your code to your apps script project
From your specifications, I understand that you want to both host the script in GitHub Enterprise (GHE) and run it from there.
Even though Apps Script API offers a good range of functionalities such as executing functions from your App remotely it is not the best option for this scenario.
With clasp you can also write Apps Script functions remotely but eventually they have to be pushed to an Apps Script project.
So, after considering these limitations I think the best option you would have is to use the right Google API in your script (such as Gmail API for example). Its functional code can all be hosted and run from your application without the need of Apps Script projects and these APIs offer the same and extended functionalities than those offered by Apps Script.
I have a small Google apps script which is invoked with an onClick event to retrieve the last row added. Next step is I need the apps script to invoke a python script internally. Is there a way to do that?
I am new to Apps script so any help is appreciated. Thank you in advance
Google Apps Script is quite similar to JavaScript itself. So, can you execute python inside JS code. I guess no.
A way that I can think of exposing that python code via Ajax Call. You can invoke the URL from the Apps Script. REST APIs come in handy to break the boundaries of languages.
But yeah, in this approach you do need to host an API. I do that using Google Cloud Functions which are really brilliant where building an API in python/nodejs is quick and easy(few minutes) with a ready HTTPS URL.
I want to use Execution api in app script to call another app script, but I see nowhere some examples to do that.
I've developed the app script api, but I don't know how to make the call in app script.
I need too to have an example to implement the oauth in this script to be able to access the app script api.
Someone can help me ?
Thanks
You may want to check this OAuth2 for Apps Script which is a library for Google Apps Script that provides the ability to create and authorize OAuth2 tokens as well as refresh them when they expire. This library uses Apps Script's new StateTokenBuilder and /usercallback endpoint to handle the redirects.
I have a Google Apps Script and am trying to use Session.getActiveUser() but get an "Uncaught ReferenceError: Session is not defined" error in the Developer Tools view. This is a Published Web App running as the User. It is happening when testing with the latest code. It is in a Google Apps for Education domain.
This may or may not be related: I had also tried to use Utilities.sleep() which gave me the same error for Utilities. I worked around this issue.
Is there an Advanced Google Service I need to turn on or some other setting I need to make? My ultimate goal is to be able to add the name of the person running the script to a cell in the spreadsheet. Once I can retrieve their name I have the rest.
Regards,
Karl
you are calling the appscript api from the HtmlService clientside javascript. no apps script apis can get called client-side, must be in your .gs or in templated html.
To call a server function from the client side, see https://developers.google.com/apps-script/guides/html/reference/run
I have Google spreadsheet with script attached to it (with the Tools->Script Editor tool).
I want to call one of script function from external Android App. Is it possible? Should I use Spreadsheet API?
Unfortunately, you cannot directly call your script from any external application.
However, you can change it to be a web application, then invoke it via an HTTP GET or POST from almost anywhere, including an Android app.
Insert new rows into Google Spreadsheet via cURL/PHP - HOW? provides an example of a web app that you could adapt.
Should I use Spreadsheet API?
Your question doesn't actually say what it is you want to do, so the answer is "it depends". You still won't be able to invoke an embedded script using the Spreadsheet API, but you will be able to read and write spreadsheet content.
Obviously the answer depends on your usecases, but have you checked the Google Appscript API?
As stated it
provides methods to remotely execute Apps Script functions