Copy security of one Google Sheet to another - google-apps-script

I have both Live, Development and Test versions of a spreadsheet.
I set up the security (protected sheets / ranges etc) in a Test version. I then want to replicate that in Live.
How can this be done via Google Apps Scripts?

Related

Updating Google spreadheets scripts automatically

Is there a way for a google spreadsheet to fetch and copy the scripts from a different spreadsheet?
I have a file that users make an individual version for them to use. The file also includes various scripts, including one that updates the sheets and formulas in case the master file changes.
However, I haven't found any way in which to update the scripts themselves. I can't deploy the script as an add-on because that function is blocked in my company.
Is there any other way to do it?
If you want to copy/update scripts in a sheet you can try using the Apps Script API.

Publish Google Sheet Add-on with REST Web Service

I want to have an add-on for Google Sheet which will give us a URL that we can use to push data into Google Sheet which isn't shared with us. Basically from a Java Project, we wish to push data into the users sheet who installed this add-on, but don't want the users to share the Google Sheet with us due to privacy reasons.
How can we achieve this in Google Apps Script (Published Add-ons) without any human intervention i.e. automatic via marketplace installation? Please guide.

Maintaining enabled APIs in Container-bound Script for a Google Sheet Template

I have a Google sheet with a Container-bound Script that makes Google Classroom API calls. I have added the spreadsheet now as a template for all teachers in my organization to copy the sheet and use it for themselves.
However, when teachers copy from the template, a new project is created in Google Console with no enabled APIs for that new project. They would have to go into the developer console and enable Classroom API for it to work....
No! This is way too much of a hassle for my fellow teachers! There has to be a better way. What am I doing wrong? How can my script keep the API calls enabled for all copies of the spreadsheet? Do I need to publish my script in a particular way or set up my project in a particular way? Whats the right approach here, guys?
This error when using the script in a copied spreadsheet. But of course, works fine in the original template file.
Google Classroom API has not been used in project project-id-xxxxxxxxxxxxxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/classroom.googleapis.com/overview?project=project-id-xxxxxxxxxxxxxxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
You should publish your script as Sheets Add-on: https://developers.google.com/apps-script/add-ons/
This gives you next benefits:
when spreadsheet (with enabled add-on) is copied, there's no need to manually enable APIs, they are stay enabled;
when you update code of your add-on, it is automatically updated for all spreadsheets where it was enabled, so you don't have to copy your changes manually.

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.

Google Apps Script - How To Publish / Install A Container-Bound Script

I have a document container-bound script, that I would like to publish, I would like to make it available to people in my google apps organization. I know the script gallery is only available to spreadsheet apps, so how do I publish it. Or, more specifically, currently the script is bound to one document, how do I make it run on all documents? My user base is fairly small, about 300 people, and I can have each one of them install it if need be.
Thanks,
Ari
There are limited options for distributing container bound scripts. When a document with a container bound script is copied, the script is also copied. So if the 300 people in your organisation copied the document they would also have a copy of that script. The issues with this techniques is that the script is only attached to that particular document and creating a new document, rather than taking another copy of the template, or opening an existing document will not include your script functionality. The other issue the script in the copies of your template becomes orphaned and you cannot push updated versions. Using Managed Libraries addresses this to a degree but the end user still needs to select the newer version of the script in the script editor.
A way to mass deploy your script in your organisation is using Google Apps Script authored Add-ons. Add-ons are installed by users and become available to every document they work on. The script behind add-ons can also easily be upgraded without any user intervention. One issue with this approach is all add-on's need to be approved by Google. This introduces a risk that Google will not publish your script as an add-on. Whilst there is a public store of add-ons after your project is approved by Google there are visibility options to restrict access and prevent there general visibility. As per add-on publication step #12:
In the "Visibility options" section, select which users will be able
to find your add-on — usually either all users or only users with an
account in your Google Apps domain.
Hopefully when add-ons leave developer preview Google Apps domains will have more control over publication and visibility (I've opened a feature request for this)