I'm working on a Google Sheets add-on in Google Apps Script and want to know how I can deploy it and install it into a Google Sheets spreadsheet whilst it is still in development (i.e. not ready to publish in the Store).
At the moment I'm forced to create my add-on embedded within an existing spreadsheet with no option of using it in another.
Has anyone achieved this yet?
Go to Publish>Test as Add On and Configure a New Test. Testing your script will run the code on a doc of your choosing.
You should be able to take it from there. If you're still having trouble, read on.
To setup the test, you'll need to specify which Document, Form, or Spreadsheet you want to it to run on, and save the test. Then you can run the test (from the Test as Add On popup, by clicking the Test button after you've saved your test setup) and it will execute your code on that document/spreadsheet/form by opening a new tab with that doc and executing your code.
To share the script with others (beyond making them use this same process for themselves by copy/pasting your script in their own Script Editor) you'll need to publish it to the Web Store; to do that you need to do all this stuff.
Hope that helps!
Yes its posible but first you need to be approved by google to publish.
Once you can publish you specify to publish only to a google group and not public (this is standard chrome store functionality)
I tried to do the same thing but was not able to. I just copied and pasted my code into the script manager to test with different spreadsheets.
Sorry, but I guess not.
Related
I'm involved in a standards development group where the meeting invitations are sent out, not as calendar invites, but as Word docs. I've written a script that allows me to take the Word doc uploaded to Google Drive, and run the script to create an entry on a Google calendar that I maintain.
At the moment, the script is unpublished, and to run it on the docs I use the "Test as Add-On" function from the script editor. That's a bit cumbersome because I have to go through the selection dialog to select the doc I want to run it on. Additionally, in the new scripts editor, it won't be possible to delete old tests and so my test dialog will end up getting filled up with every run of the script I've ever carried out.
It would be much better if I could have the script available to me, and me only, from the Extensions->Add-Ons menu when I open a doc. The script is not suitable for general publication: it works only on docs with the exact format of these meeting notices, so it should only be run by someone who knows what they're doing, and it accesses a calendar that I own, so I don't want to make it public. But I would like to be able to put it into some kind of "deployed" state so that, as I say, when I open any doc when I'm logged in as me, the script is just available directly from the Add-Ons menu.
Is there any way to achieve this? Or is there an alternative approach possible to this general problem, of having a script that you want to run on multiple documents that you own without having to formally publish it?
One option to "test as add-on" without publishing the script as an editor add-on, is to use installable triggers instead of simple triggers. This triggers should be created by using code in order to avoid having to add any code to each spreadsheet.
If you are determined to take the publishing path you can set your add-on listing to be "unlisted", this means that the add-on will not appear on the Google Workspace Marketplace, people will need to know the installation URL to be able to install the add-on.
Other options:
If you have a Google Workspace account you could publish the add-on privately for your domain. If you don't have this account type or if this is "not good enough", you might make your Google Apps Script add-on publicly installable but limit its core features to be used only by you by making use of a dynamic custom menu. For details please checkout Editor add-on authorization
The dynamic custom menu might based on a setting depending on the user email address. To make this work, as the Session.getActiveUser() requires authorization to run, it can't be executed by simple triggers, but you might implement a workflow to save it or a flag, i.e. add an option to the custom menu to initialize the editor add-on.
Another option is to make the dynamic custom menu based on the spreadsheet structure and/or content.
References
Installable Triggers
Enable and configure the Google Workspace Marketplace SDK
Related
Google Apps Script: Dynamically creating spreadsheet menu items
Publish an add-on privately
I created a small app on top of a spreadsheet (with GAS and HTML, CSS) and I deployed it.
Users can access to it without having to enter in the spreadsheet.
It works really well but i'm not able to see even the basic analytics (for eg. the number of viewers)
Thanks
Go to the project overview page. In the Google Apps Script web IDE, on the lefmost sidepanel click on Overview.
Also, if you have starred your project, go to https://script.google.com/home/starred
Rather than "viewers" you will see "users". If you have set your web-app as execute as you by anyone even anonymous, you will see only one user, you, as this page show the users that exectuted the scripts like the doGet function and the server-side functions called through google.script.run.
Note: https://script.google.com keep execution logs for the last 7 days. If you need to keep the logs longer you have to use another place to keep these logs, i.e. Cloud Logging (requires a Google Cloud standard project), Google Sheets spreadsheet.
Resources
https://developers.google.com/apps-script/guides/logging
Related
Effective way to debug a Google Apps Script Web App
When I click on Tools -> Script Editor in a Google Doc, I am presented with the following screen, whereas before I would be directed straight to the script editor:
I am worried that there are now two instances of my script. Is there a place I can easily see and manage the scripts and projects in Google Apps Script? I have checked out Google Cloud Platform Project through the script editor menu (Resources -> Cloud Platform project), but the resulting dashboard is not very intuitive to me.
As some background: I was trying to test Google Apps Script code deployment using Clasp and after the test, I wound up with the above issue. I don't know if the issue came about when I used Clasp commands or if it was when I copied the existing document before trying out Clasp.
Thank you for taking the time to read this. Any info is appreciated.
You can bind multiple script projects to a container (the container in this case being your document).
When you have multiple projects bound to a container and you open the script editor, you are provided with a menu with a list of your projects.
You can easily delete the duplicate project. Just select it, and then when you're in the Apps Script GUI editor, navigate to File > Delete Project.
G-Suite Developer Hub
You can access all of your scripts at G-Suite Developer Hub. You can even monitor script performance from there.
Same Named Scripts
You will want to avoid scripts with the same name within a project but it's okay if they are in different projects.
Backups
If you want to make a backup of a project you can just copy it. In the case of a container app you can make a copy of the container and you will be making a copy of the scripts it contains at the same time.
I'd like to manage spreadsheets (uploaded by a client via API) over google engine. I created test spreadsheet extended by functions in .gs script (which works great if I add them via online editor) but I do not know how to apply such a .gs script to every uploaded spreadsheet automatically (possibly via API).
Moreover, I do not want to share this .gs file by publishing it as an extension (because of security policies).
Updated: I also tried copying existing spreadsheet with working gs script and overwriting its spreadsheet data via API (instead of uploading new one) - it's overwritten data successfully but unfortunately lost gs script. Details are described in separate (bounty) question: Custom google app script doesn't work after copying spreadsheet with google java client
So I've even tried copying using plain HTTP methods since I thought it might be a problem with Java SDK but it still didn't work which means that there is some problem at google side (or something is really unclear) with service accounts.
After all I solved the problem with another approach.
First I copy spreadsheet with script attached to it to my service account (as I described in this Custom google app script doesn't work after copying spreadsheet with google java client topic). The file is copied with broken script.
Then I make user authorize using google's oauth (this tutorial shows how https://developers.google.com/identity/protocols/OAuth2WebServer#overview)
And then on his behalf I perform copying.
Finally the file is on his private drive which is the biggest downside of this solution but at least the script works which was my main goal.
Hope it helps ;)
You can publish a google script without it going on the Marketplace. If you make a Google group you can publish in such a way that only members of your google group can see it. If your google group only has you, only you can see it. Then it will be on all of your spread sheets.
The downside being that google will never let you remove it from their server, only unpublish it.
You can create a stand-alone script that is independent of any spreadsheet. This script would contain any methods/functions needed to create and manipulate spreadsheets according to your use case. Furthermore you could deploy the script as a web-app and implement a doGet() or doPost() method. Whenever a user uploads spreadsheet data via API you can call the web app with the information and have it create spreadsheets as needed.
I've been following the guide found here: https://developers.google.com/apps-script/articles/twitter_tutorial
About creating a twitter app.
I've been looking at the part below:
To get started, copy this spreadsheet containing the script for this tutorial. Once you've got your own copy of the spreadsheet, open it and you will notice the spreadsheet will be empty; that is intentional, as we won't be using any of the spreadsheet's cells in this tutorial.The first thing you need to do is publish your script as a service. To do this, open the script editor by clicking Tools > Script Editor... In the new window, click Publish > Publish as Service...
This doesn't actually work at all.
If I open the spreadsheet and click Tools > Script Editor.. I'm taken to the script wizard. It then give me the option of creating a new script. The script can only be published to gallery, or as a web app. Where is the publish as service option?
Thanks
I checked on the tutorial page and it seems indeed that the template spreadsheet has not script included...
But the full code is still published at the end of the same page so you could copy/paste the full code in the script editor (choose new code from the wizard and delete everything in there ) and start from there.
About the "publish as service" this is the old name of what is now known as deploy as webapp, the procedure is slightly different and is described here, you will need to first save a version (manage version in the file menu) and you will get 2 urls, one for development and one for use, both will run from your browser starting with the doGet() function.
The remaining part of the tutorial about initialisation and authorization from the spreadsheet menu is unchanged, just follow the tutorial instructions.
Hoping it will help you,