3

I work for a company that is very google-centric.

I want to reuse google apps script code between google sheets (but only specific google sheets). Only people within the company should have access to this script. When a copy of a google sheet with attached code is made, the code should copy (currently only the main file copies when I do this, for some reason). No other sheet should have this code attached.

Ideally, though I guess this may be unrelated, I want to store the code in our internal repository.

How would I do this?

Thank you!

Similar: Distributing Google Apps Scripts for Sheets in your company network (but I don't want it installed on all google sheets, just ones I chose and copies of those).

hackpoetic
  • 75
  • 5
  • Unfortunately you need to put in the cmd+c --> cmd+v ;) People can still copy the code form the editor and paste it in all other sheets they want. – RemcoE33 Aug 23 '22 at 19:33
  • Perhaps you should look at [Libraries](https://developers.google.com/apps-script/guides/libraries) – TheWizEd Aug 23 '22 at 20:12
  • If this answered your question, please click the accept button on the left (check icon). By doing so, other people in the community, who may have the same concern as you, will know that theirs can be resolved. If the accept button is unavailable to you, feel free to tell me. [How to accept answer](https://stackoverflow.com/help/accepted-answer) – Ricardo Jose Velasquez Cruz Aug 26 '22 at 22:31

1 Answers1

1

Creating Custom Templates for your organization

If you are using Google Workspace with your organization. You could create a Google Sheet with the Apps Script code that you need and make it as a template for the domain/organization.

You should be able to make the template available for the organization and limit the users that can create or submit templates.

Add-ons with Custom Template (Apps Script)

You can also turn on the option to have templates with Add-ons, in case your project becomes one in the future when publishing the Apps Script project or deploying it as an Add-On for the organization.

This can also be considered as another alternative if you think about it. Building the Apps Script project and later publishing it as an Add-on as "Private"

There is an excellent thread discussing this particular scenario and also mentions the suggested libraries from the comments.

References:

Rubén
  • 34,714
  • 9
  • 70
  • 166