1

Google recently made available its new Google Script API, and I think it is a good opportunity to make a long awaited project happen.

The context is as follows:

  • A few users, all in a corporate GSuite domain share ~100 sheets, that have the same purpose.

  • I would like to augment these sheets with a sidebar, that displays additional information, etc.

  • I want to process to be seamless for the users (ie. no installation, and auto-open when on one of the sheets in the project).

These last requirements force me to use a bound script, bound to each and every file in the project. So far, making sure every sheet had the same script was very difficult, and I gave up.

However, the newest API gives me hope. I have looked at the documentation, but it does not really say one way or an other, hence my question:

Can I deploy bound scripts using Google Script API?

Maxime
  • 1,245
  • 2
  • 14
  • 24
  • Do you want to create a project of bound script type in Spreadsheet? If my understanding is correct, it can be achieved using [projects.create](https://developers.google.com/apps-script/api/reference/rest/v1/projects/create) Apps Script API. But I'm not sure whether this works and is useful in your environment. It is required to try. If I misunderstand your question, I'm sorry. – Tanaike Feb 06 '18 at 11:41
  • Hello @Tanaike, thank you for your help. projects.create is definitively half of the solution. The other half would be retrieving the project created later on, from the Google Sheet's ID, but it seems that projects.get can only use a project ID... Any idea? – Maxime Feb 06 '18 at 13:38
  • Thank you for your reply. Unfortunately, in the current situation, the project in the spreadsheet cannot be retrieved using Apps Script API. Because "projects.get" doesn't return the parent ID (in your situation, Spreadsheet ID). Although I think that this might be a bug, I'm not sure the detail. So I reported this situation to https://issuetracker.google.com/issues/71941200 – Tanaike Feb 06 '18 at 21:54

2 Answers2

1

It should be possible (for the most part).

You might run into a few issues with automatically opening the sidebar but everything else seems viable.

You just have to write a script to fetch the file Ids of the 100+ sheets in question, set up a stand-alone or bound script as the master copy, and use the api's projects::getContent() method to get the script files from the master and propagate that to the target sheets using the projects::updateContent() method. You'd probably also need to create new projects for bound scripts on those sheets using the projects::create() method.

TheAddonDepot
  • 8,408
  • 2
  • 20
  • 30
  • Thank you for your help. I have a question, related to the comments of the question. How would you get the projectId of the bound project (since projects::updateContent() requires a projectId) from the related sheetIs? – Maxime Feb 07 '18 at 07:22
  • The method requires a scriptId, which is also returned in the JSON response when creating a project. – TheAddonDepot Feb 07 '18 at 11:36
0

The docs states that you can publish your scripts (bound or standalone) as Add-ons. That's the most possible direction you're headed.

Apps Script lets you publish your script as an add-on so other users can install it from the add-on store.

MikaelF
  • 3,518
  • 4
  • 20
  • 33
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
  • Thank you for your answer. I would however prefer by far a solution where users don't have anything to do, it just works when they open a sheet that's part of the program. – Maxime Feb 06 '18 at 16:12