'Updating multiple appscript projects from one appscript

I have scenario where I have more than 60 sheet, and all have appscript project behind them running and managing those sheet. I want to updat/control those appscript projects all at once, from one different project. So that I don't have to manually go and update them.

I know this solution where we can update it by manually getting OAuth Token from single appscript project but, Is there any way we can just mention sheetID and it updates project behind all those sheet all at once?



Solution 1:[1]

From the question

Is there any way we can just mention sheetID and it updates project behind all those sheet all at once?

There is no direct way to do this. Related issue Retrieving Project ID of Container-Bound script (created in 2018, as of the end of 2021 it still has the "New" status).

Assuming that by "SheetID" you mean the spreadsheet id, it's possible to use the Spreadsheet Service and the Drive Service to get a Class Spreadsheet or Class File object, respectively. Unfortunately those classes hasn't any method to retrieve the bounded Google Apps Script project.

The same for the Sheets API, Drive API and the Apps Script API.

The indirect way is to build a list of spreadsheets and their respective bounded scripts but it's clear that this is not what you are looking for. Anyway, build the list of spreadsheet/script projects pairs and store it somewhere (it might be an spreadsheet if the list is not humongous. CLAPS has a command to retrieve the list of the recent projects, and it's possible to get the container id from the script project metadata (see https://developers.google.com/apps-script/api/reference/rest/v1/projects/get)

Considering the above, the advice to make it easier to maintain your scripts "for the next time" is to either use a library or to create and add-on.

Resources

Related

Solution 2:[2]

If you're asking can you reference different codes from the same document but not the same sheet in a new code, the answer is yes. But, there is no way to manipulate this code other than editing the original code. I would recommend manually getting an OAuth Token from a single Apps Script Rroject.

Solution 3:[3]

A different way to control those Spreadsheets can be with a NodeJS project locally, using Clasp and Multi-clasp2 (https://www.npmjs.com/package/multi-clasp2).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 taylor.2317
Solution 3 Fabrizio Antonangeli