I have refactored my bound GAS script into a standalone script (for re-use) and decoupled the google sheets specific calls. I would like to be able to invoke the standalone google app script from within a bound Google Sheets script, is there a way to do this?
Related
I've exploring possibilities here to dimish the workload for users when first running the sets of script I'd have built into the spreadsheet.
One of the functions requires Sheets API and having the user manually enable it would be a killer. I've read through it and couldn't find a clear answer as to the possibility to add this advanced service together via script when the user is first authorizing the script to run...
This is what the user would have to do instead:
Thanks for your input!
Although, unfortunately, from your question, I cannot know your actual situation, in order to achieve your goal, I thought of the following 3 patterns.
Pattern 1:
In this pattern, Sheets API is directly used.
If the Google Apps Script project (GAS project) is the container-bound script, it adds Sheets API to appsscript.json of the GAS project using Google Apps Script API.
In this case, it is required to link Google Cloud Platform Project to Google Apps Script Project. Ref
If the Google Apps Script project (GAS project) is the standalone script, it adds Sheets API to appsscript.json of the GAS project using Drive API.
By this, Sheets API can be directly used with the GAS project.
Pattern 2:
In this pattern, Sheets API is directly used. The flow of this pattern is as follows.
Prepare a Google Spreadsheet including the container-bound script.
The container-bound script has the script you want to use and Sheets API has already been enabled.
When you want to make users use this script, by copying this Spreadsheet, the user can use the script that Sheets API has already been enabled.
I thought that this pattern might be simpler.
Pattern 3:
In this pattern, Sheets API is indirectly used. The flow of this pattern is as follows.
Create a new Google Apps Script project and enable Sheets API at Advanced Google services.
Deploy the GAS project as the Web Apps.
When you use Sheets API at your GAS project, you can indirectly use Sheets API by accessing Web Apps using the script.
In this case, Sheets API has already been enabled at the Web Apps side. So, your GAS project of the client side is not required to enable Sheets API.
In this case, also, I think that it is required to check the number of concurrent accesses. Ref
References:
REST Resource: projects of Google Apps Script API
Files: update of Drive API
Web Apps
I'm working on an automated Google Apps Script where I have a template Google Sheet where it has a container-bound script connected to specific Cloud Platform Project (Standard Project).
When I copy the sheet programmatically, the container-bound script is copied correctly. However, the container-bound script is assigned to a dynamic Cloud Platform Project.
Is there a way using Google Apps Script APIs to change the Cloud Platform Project from code?
I am using the Drive API, authenticated via a service account, to copy a "master" Google Sheet that has an Apps Script attached. The Apps Script is simple and creates a custom menu in the Google Sheet. However, when the Google Sheet is copied from Drive and then accessed via the Google Sheets API, the attached apps script doesn't execute the onOpen function. I'm guessing there is some strange ownership/permissions issue that is preventing the onOpen from "activating" when it's copied with the service account and then given domain-wide "write" permissions.
On open events, simple and installable, are triggered only when a user opens a spreadsheet not by API actions.
Reference
https://developers.google.com/apps-script/guides/triggers/
Is there a way to get the id of a script embedded in a spreadsheet (not the id of the spreadsheet) from another script (in other file)?
I have a main standalone script that copies a spreadsheet that contains a script (web app code). I need to get the id of this script and use it to create a deployment with the apps script API REST.
Is there any other way to programmatically deploy a bounded web app script in a spreadsheet?
Apologies for my bad English, I´m using the translator
In order to achieve Is there any other way to programmatically deploy a bounded web app script in a spreadsheet?, at first, it is required to retrieve the script ID of the container-bound script.
But, unfortunately, in the current stage, the script ID of the container-bound script cannot still be retrieved from outside of the project using only Google Apps Script. And also, the the script ID of the container-bound script cannot be retrieved from the file ID of the parent Google Docs file. This has already been reported to the Google issue tracker as the Feature Request. Ref
When the script ID of the container-bound script can be retrieved, you can use "REST Resource: projects.deployments" in Apps Script API.
Note:
If the script for retrieving the script ID is in the same project, the script ID can be retrieved using ScriptApp.getScriptId().
The file ID of Google Docs can be retrieved from the script ID of the container-bound script using the method of "Method: projects.get" in Apps Script API. But in the current stage, the contrary cannot be done.
References:
getScriptId()
Method: projects.get
REST Resource: projects.deployments
I have been looking for a way to interact with my google sheets (and other services) from Excel (and other desktop applications).
For example:
I get a report from a work system and my boss asks me to update the information in the google sheets so that our site is up to date with the latest information.
What would be great (and easy for me) would be to use a VBA script in my spreadsheet to turn all my data in http requests and then do the heavy lifting with Google Apps Script in the cloud and finally updating the Google Sheets with the associated API.
When I look at the oAuth2 playground I can't find a way to enable Google Apps script, as I have successfully done so with other APIs.
(to be clear, I don't want to do oAuth2 with in GAS - which is a lot of the other questions that get raised)
Is this a hard problem or is there a solution?
There is currently no way of calling a Google Apps Script from an external program. You do have a few other options:
Import the relevant data into Google Sheets manually and use Google Apps Script to process it as needed, possibly making use of time-based triggers to handle the processing automatically.
Use the Google Spreadsheets API. Unlike Apps Script, this API is built to be called from other programs and can manipulate Google Sheets. However, it is a bit more difficult to use than Apps Script. Once data has been moved into a Google Sheet, a separate Apps Script can be used to manipulate it.