Google Doc Script onEdit - google-apps-script

I want to build a Google Doc Extension.
Google Spreadsheets has an onEdit trigger, Google Documents don't seem to: https://developers.google.com/apps-script/understanding_triggers
Is there a way for me to handle user input (typing) cleanly?

Not in Apps Script. If you write an app using the Drive API, you can use the Realtime API https://developers.google.com/drive/realtime/

Related

Is there a way to eanble Sheet API via Apps Script?

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

Is it possible to run a Google App Script from Google Colab?

I have a Google Colab Workbook that does some scrapping and saves the scrapped files in my Google Drive and I also have a Google App Script that manipulates these files in Google Spreadsheet.
Is there a way to trigger this Google App Script directly from Google Colab? So at the end of my scrapping it does all the things I need it to do, without the need to open Google Apps Script.
I know I could write code in Google Colab that does exactly what the Google App Script does. But I would like to avoid that.
You might use Google Apps Script to create a web-app or you might use the Google Apps Script API then call them from Google Colaboratory by doing a HTTP request. The method to be called to execute a Google Apps Script function is script.run.
Related
python requests POST with header and parameters
How to make a Post request to an API using Google Colab
Resources
https://developers.google.com/apps-script/api/quickstart/python
https://developers.google.com/apps-script/api/how-tos/execute#python

Can I do getCursor() on Google script bounded on google spreadsheet?

I'm playing with google script. I want to execute getCursor() on the google script that's bounded to a google spreadsheet, but it seems it doesn't work. I can successfully open the google docs by DocumentApp.openbyId() on my google spreadsheet script, but getCursor() returns null although both google docs and google spreadsheet files are owned by me. Is it just impossible? or is there any way to make it work?
Thanks in advance.
No, you cannot use getCursor in a Sheet because it does not exist.
getCursor() is a method for the Document class from the Document Service.
No such method exists in Spreadsheet Service.
As an alternative, have you tried SpreadsheetApp.getActiveRange()?

Is there a way to make a google apps script always available? (google form/response sheet)

I have a google apps script that I use on the response sheet that results from a google form. I would like this script to always be available on any response sheet that gets created from a google form. I think I need to turn my script into an add-on, but I haven't found a simple explanation on how to do that.

Using oAuth2 to send requests to Google Apps Script (i.e. GAS as google API)

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.