I have written a Google Apps Script script using the Apps Script App in Google Suite. I also created a spreadsheet using the same account. I want to add a button to my spreadsheet that runs the script when I click it. I added an image, right clicked, hit three circles and selected the "Assign script" option. Problem: I can only assign scripts that appear under tools>script editor. I cannot assign the script that I previously wrote by opening the Apps Script app directly (in the same account). I can copy paste the whole thing into the spreadsheet's scripts, but then I have to maintain two versions. What I want I want to directly assign the script that I wrote earlier to the button.
Is this possible? Thanks.
Issue:
Only functions in the script bound to your spreadsheet can be assigned to a clickable image/drawing:
Use libraries:
As a workaround, I'd suggest creating a library for your standalone script (so that the script's functions can be reused in other scripts) and call it on the script bound to your spreadsheet.
You can do it the following way:
STANDALONEin this example) where you have your desired function:File > Project Propertiesand copy theProject key: see Sharing a library.Resources > Librariesand paste the previousProject keyinto theAdd a Librarytext box: see Gaining access to a library and including it in your project.Identifierand the scriptVersion:Identifier:boundFunctionto your clickable image.Reference: