Cannot find the Google Script library I have already created - google-apps-script

I finally got around to putting my script into a reusable library that I can share between other Google Sheets scripts. I have the URL (it opens to just the signature of the library functions) and the deployment ID.
It is definitely connected and working with my Google Sheet script.
I have no idea where the source code is stored so I can edit it! Believe me, I have Googled this. There is discussion on how to add your library to your script, but I could not find anything about editing an existing library.
I have searched my Google Drive.
I have looked in my Google Docs.
I have tried putting a break point in my script and stepping into the library function. (Note that this article says stepping into the library function should work).
Bubkis! Where is the darned code stored?!?!
thanks in advance

I think I figured this out. When you initially create the library, you are in a script. THIS is where the code is (I had assumed that a new library was created with this code.)

Related

Is it possible to add the same custom menu to every new google document? The goal is to make a local script function like an installed app

Is it possible to add the same custom menu to every new google document? The goal is to make a local script function like an installed app.
This seems like it should be easy but I can't seem to find a way to do it. I'm using a standard account for personal use. I've created a script attached to the original document and also made copy as a stand alone script. (I'm not sure that makes a difference.) I've searched and read about deployment and it seems to be only useful for a domain account or publicly as an app. I've played a little with scripting but this is the first attempt to get a script working "globally".
Any help will be most appreciated.
I found a way to do this in an old example at: https://sites.google.com/site/scriptsexamples/custom-methods/2d-arrays-library.
The script is in a project and that needs to be connected to the current doc. The onOpen() script is a UI that contains the line:
.addItem('Select Phrase', 'PS.showPrompt')
where PS is the name of the attached library. Once this is done, as you said, you can make a copy and use it with the script active.
It is a little slow as they describe about using a library, but is make the code easier to maintain. Thanks to all for the direction to look.
What we do is create a copy of the original document (the document with the attached google apps script). The script is copied along with it and the copied document has the exact same functionality (menus, custom functions, etc).
You could create a Google Docs Add-On using an independent Apps Script script and then install your Add-On globally. For more information regarding its installation check this documentation. However you would need to run this Add-On on the new documents to get your desired menu.

Using Google Apps Script Libraries

I have read all Google documentation on managing and creating libraries, yet I still do not know if they are an appropriate option for the problem I am trying to solve.
I know how to save a version of a standalone script. I know how to add the library to a spreadsheet via the script editor. But I don't understand, very simply, how to trigger the library script within the new spreadsheet.
I have a spreadsheet that serves as an often-copied template within my organization. The template contains a script that (onOpen) accesses data on a separate spreadsheet (a master database) and sets those values on a tab called "admin." The desired result is to have a copy of the master database living within the template sheet (and every subsequent copy of the template sheet). At this point, there are thousands of copies of the template sheet, each running that same script.
Whenever I have to change the script, I have to change it within thousands of sheets. Can I use a library instead? I'd like to be able to create a new version of the script in the library and have all sheets connected to that library experience the change. I understand that the library needs to be in development mode (within each sheet) to do this. I also understand that in order to make this switch, I will probably still have to go into each sheet to add the library. I'm just hoping it will be the last time I have to do such a tedious task.
Any advice or links to solid info is appreciated.
besides making an add-on (already covered in another answer) I will answer your libraries question. They will work for you. What you are missing is the "connect" part.
For this you want to trigger the library code from say, onOpen. The onOpen in the library is not enough and not detected by apps script. Instead each of your spreadsheet's script needs an onOpen(e) which just calls yourlibrary.onOpen(e).
since those "hook" calls rarely change, specially once you stabilize your library api, and using it in "development" mode will let you modify just the library.
whenever one of those hooks needs to change (say a callback from an html GUI needs a new parameter) you need to update all the spreadsheets. to avoid this, make all your callbacks receive a single json object instead of multiple parameters.
Sorry if I am repeating other answers, but I would like to sum up and add something:
You can access your library functions as follows:
From the app using the library you go to the Resources/Libraries. You can see the library name under "Identifier". On the same line where you can select Development mode.
Library name found in resources
Now in your library you have for example a function
function onOpen(e)
{
Browser.msgBox("HELLO!");
}
In the spreadsheet app you wish to access it you use the library name found in the resources, for example "testlibrary"
function onOpen(e)
{
testlibrary.onOpen(e);
}
Now if you have development mode on, the modifications to functions in the library update automatically to your application (spreadsheet) as long as the user using the application has edit access in your library script.
If anyone using your spreadsheet has a restricted access to your library script (meaning only view access) or development selection is off in the application, you have to go to the application's script, Resources/Libraries and select the most recent version of your library to be used in the app everytime you update the library and save a new version of it.
Still, especially if you are using mostly only the onOpen function , I would recommend using the library rather than copy-pasting the function to the script of each spreadsheet, as it is easier to track which scripts are up to date and it is easier to avoid errors and differences between the scripts.
Even in the more restricted case, if you update function in library - as long as you are already calling it in the app - all you have to do is select the new version of the library used.
I hope I had anything to give in this conversation and my language was appropriate, this was my first answer..
A good question Melly. I've been through a bunch of the documentation and some tutorials on this subject but haven't tried adding any libraries yet. My understanding is that once you are connected to a library all you have to do is call the applicable functions. That once a library is connected the functions in the library become an extension of all the other Apps Script classes available in the script editor.

Noob: Make my scripts available to me

Sorry for the dumb question, I have tried to search but did not find an answer. Please point if the answer is already been answered.
I am practicing writing my first google scripts (apps). If I create them from within a sheet they are only available to that sheet (bound). I can create them by creating a new script but I don't know how to make them available to all of my spreadsheets (not just one). THe scripts I downloaded from the store show up but how do I add my scripts.
I do not want to publish these to the world, I just want them available to me so I can access them from any sheet I am working with.
Basic question but I am having trouble understanding the process.
Thanks,
A script bound to a spreadsheet is only available from that sheet, you won't be able to access it from another sheet.
You can also create a script file (not related to any other document) but this will not be available from sheets.
This is how it is meant to be.
One thing you can do to use functions you eventually develop in a script is to make a Library of it, the functions in that library will be available to other scripts if you explicitly link the new script to the library (in the script editor > ressources>library) but this procedure is not as simple as the workflow you imagine in your question : each document will have to contain a minimal piece of code that will call the script library functions.
The last option to get create a "spreadsheet-with-script" and to simply make copies of this original spreadsheet (that has a script) and that copies will have the script copied as well.

How to share one Google Apps script between few documents?

I wrote short script for numbering of document sections. But every time when I want to use it in new document I must create new copy of that. I tryed to publish the script by option "Deploy as web app..." but it is not clear how to connect it in new document. Is it possible? I have few documents in Google Drive and few copies of same script for each of document. Can I connect every document to one script? Thanks a lot!
This is not possible for now, there is an open enhancement request that you could star to mark your interest and be informed if something new comes up...
I had a similar problem.
The leaner solution that I was able to imagine is to keep the function in a saparate, shared script file. In the spreadsheet script, you will use the shared script file as a library.
In this way, your logic remains in a single copy, the actual part of the logic that is copied several time is only a call to a shared function.

Accessing scripts once the script has been written

I followed the tutorial here:
https://developers.google.com/apps-script/articles/gmail_filter_sms#section3
I'd like to go back and edit the time-frame of the trigger but I can't find the script. It's been working for several days now and continues to work but I can't seem to find it anywhere.
Can someone lend a hand and tell me where I can go to edit the script I had originally saved?
Thanks!
According to the tutorial you were following, you created a container-bound script. You can read about scripts and containers here to get to know the differences.
The tutorial creates a script in the context of a spreadsheet (see steps 5-6 here), and you should be able to find the script pretty easily once you track down what spreadsheet you made it in. I'm fairly certain that it can still be executed if the spreadsheet is in your trash, but I don't have any documentation to back that up.