Multiple copies of script in Google Apps Script - google-apps-script

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.

Related

Where can i see the analytics of an Google App Script Deployment?

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

How do I create a User-managed Cloud Platform project?

I created a script inside a Google Docs document. I want to use it in all my docs documents, so inside the script editor I clicked Publish -> Deploy as Docs add-on...
However, the following alert prompts:
What should I do in order to use my script?
Please check out the instructions that have been documented under:
Google Cloud Platform Projects > Switching to a different standard GCP project.
Sharing the steps here too, for reference:
Create a new Google Cloud Platform (GCP) project - instructions available here if you don't already have one.
in case you already have a GCP project configured, switch to that project via the cloud console.
Get the Project ID/number - instructions available here
Then go back to your script from the Apps Script browser editor and navigate to Resources > Cloud Platform project
In the Change Project section, paste the project number you copied into the text field, then click Set Project & finally Confirm on the subsequent page.
Personally, I had difficulties following through step 2 i.e. getting the project number so here's where you find it -

Can I Associate an Apps Script with or Deploy an Apps Script to Google Drive?

I have some scripts which make copies of files and folders in Google Drive so users won't have to do this manually, but at the moment these scripts are just script files sitting in the drive and users need to open and run the script. I don't want the users to have to click Run > Run Function, and see the code, etc, so I'm looking for a better way to deploy these.
Ideally, the scripts would appear in a dropdown menu when the users went to their Drive. Is there a way to do this?
I'm considering just creating a Doc. Then users will have to open the doc whenever they want to run one of the scripts, but at least they won't see all the guts. I'm new to Apps script, so I might be overlooking an obvious, better solution...
Google Apps Script doesn't have a way to add UI elements to Google Drive web UI.
I think that this could be achieved by creating a Chrome Extension but I didn't tried this yet.
Reference
https://developers.google.com/apps-script/guides/menus
https://developers.google.com/apps-script/guides/dialogs

Is it possible to convert a bound script to a standalone script?

I thought by using "Save a Copy" from a bound script, I would create a standalone version.
After I copied the script, I wasn't able to find the script from my Google Drive. Is it possible to do what I'm trying to do?
When you "make a copy" of a bound script you end up with two script projects bound to the same container.
As far as I know the only option is to create a new stand alone script from scratch, re-create any files, and copy/paste the contents over manually.
Depending on your goal, another option is to keep the existing script container-bound, but access it as a library from a stand-alone script.
https://developers.google.com/apps-script/guide_libraries
2018 update:
Google now offers an Apps Script API for remote management of Apps Scripts, and the CLASP utility for managing Apps Script from the command line. You can now use these to copy the contents of a container bound apps script and populate a stand-alone script.
https://developers.google.com/apps-script/api/
https://github.com/google/clasp

Deploy and use Google Sheets add-on with Google Apps Script

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.