4

I created a container-bound script inside of a Google Document. Since then, I created a stand-alone script to replace this container-bound script, but I never deleted the initial container-bound project from the original document.

The new stand-alone script makes a copy of the original document using it as a template for a new document. Because I forgot to delete the initial project from the original document, a copy of the script was also made each time. I now have an extremely large number of copies of the script in my Google Apps Script Dashboard (script.google.com) as shown in this image: View of my Google Apps Script Dashboard showing multiple copies of same script

I would like to delete every copy of this script from the dashboard. While I can right-click a single instance and select "Delete forever," like so:

Delete forever

I have not been able to find a way to select multiple instances simultaneously. Because I have such a large number of copies, selecting and deleting each instance one-by-one would take a prohibitive amount of time.

Perhaps I have simply not yet discovered how to select multiple instances. However, if it is not possible to select multiple instances in the dashboard, I am looking for a way to delete this script from each container programmatically without deleting the containers, themselves.

For instance, ideally, I would prefer to just type "TicketTemplate" into the search box within the Google Apps Script dashboard, select all, and delete all. But barring that possibility, I am hoping there is a way to do this programmatically using GAS. However, simply iterating through my files in Drive and deleting the files that contain this script is not an option. It must remove the script from the file without deleting the file itself.

I looked for a potential solution using GAS, say perhaps, using the DriveApp class, but I have been unable to figure out how to target the script within the container/file.

Thanks in advance for the help!

snoski
  • 174
  • 11
  • 2
    Try [tag:google-apps-script-api] – TheMaster Oct 21 '18 at 21:06
  • I appreciate the suggestion @I'-'I ; however, I am completely uneducated in google-apps-script-api. If it is not possible to do what I am trying to do within GAS itself, then I will try the API, but I would prefer to know whether or not there is a solution directly in the dashboard or in GAS before I try other options. If I must use the API, I would appreciate a bit more info how to do this. Thank you. – snoski Oct 21 '18 at 21:33
  • @Tanaike Problem is "listing" all container bound scripts with the name "TicketTemplate". The more I think about it, The more it seems impossible with the current api limitations. – TheMaster Oct 21 '18 at 22:05
  • snoski I don't think it's programmatically possible yet. https://issuetracker.google.com/issues/117105106 filed by @tehhowch – TheMaster Oct 21 '18 at 22:21
  • 1
    Although I'm not sure whether this is useful for OP's situation, when the current APIs are used, I thought a workaround. How about this flow? 1. Copy the spreadsheet without the bound scripts using Sheets API. 2. Delete the original spreadsheet with the bound script using Drive API. 3. Modify the spreadsheet ID of the standalone script using manual and/or apps script api. By this, the bound script can be deleted and the spreadsheet without the bound script can be created. – Tanaike Oct 21 '18 at 22:24
  • @Tanaike, your library does look like it will be extremely helpful if using the API is the only way of accomplishing what I'm trying to do as it gets me one step closer to "simple" GAS. As I mentioned previously, I would prefer to use just GAS if possible (i.e. using DriveApp and/or ScriptApp, etc.). If I were to use your library, I would assume that I would use your 'updateProjectByBlob(projectId, blob)' method. How exactly would I use this method to delete the script? From my novice level of education, "update" seems different than "delete." – snoski Oct 21 '18 at 22:31
  • @'-'I Thank you for your comment. Also I think that the container-bound script cannot be directly deleted by the current API, as you say. Because I had noticed I misunderstood about OP's issue, I had thought another proposal. – Tanaike Oct 21 '18 at 22:37
  • @snoski I'm sorry. I had misunderstood about your situation. I noticed that my first proposal cannot be used for your situation. The container-bound script cannot be directly deleted by the current API. So I proposed a workaround. Could you please confirm it? My next proposal can be created by Google Apps Script. – Tanaike Oct 21 '18 at 22:37
  • @Tanaike Never realized Sheets API can be used like that :) But Seems like a really big project/workaround. – TheMaster Oct 21 '18 at 22:44
  • @snoski, Why would we divert you to a twisted way, If there was a simple way using "simple" GAS ? API can be used with GAS. But it's not "simple". – TheMaster Oct 21 '18 at 22:48
  • @I'-'I If Drive API can get the bound script, the script will become much simple. Unfortunately, the current situation complicates the workaround. By the way, the sample script for copying without the bound script is [this](https://stackoverflow.com/questions/51790433/copying-a-spreadsheet-copies-all-linked-files-as-well/51795860#51795860). Because the bound script cannot be directly deleted, I have used this. I wish I could also copy the spreadsheet ID. – Tanaike Oct 21 '18 at 22:53
  • 1
    @Tanaike Yes, After you mentioned the workaround, I also figured the `get-create` combo. If it was at least possible to get the ``script-id`` from the ``spreadsheet-id``, it'll be really easy. – TheMaster Oct 21 '18 at 22:56
  • 2
    @I'-'I In this method, the spreadsheet is changed. This also complicates OP's workaround. And, yes. I think so. So I have reported this. https://issuetracker.google.com/issues/111149037 – Tanaike Oct 21 '18 at 23:04
  • 1
    At this time, it appears to be clear that what I want to accomplish is not currently possible using the desired tools. @Tanaike, thank you for your suggestion. I believe I can follow the instructions you've provided. I prefer not to do it this way if possible because I believe it would clear the revision history of the containing Documents. I prefer to preserve the revision history if possible. This issue isn't extremely urgent for me (more just an annoyance), so I think I will just wait for now and see if Google completes these feature requests. Thanks again. – snoski Oct 22 '18 at 00:10
  • @snoski If you want to delete the projects while the revisions are included, my 2nd workaround cannot be used for this situation, because when the spreadsheet is copied, the revisions are also cleared. I think that in the current stage, there might be no methods for resolving your issue using a script. When APIs are updated in the future, your issue might be resolved. But I apologize that I couldn't resolve your issue soon. – Tanaike Oct 22 '18 at 00:41

0 Answers0