0
votes

I want different users to be able to edit my Google sheet and my scripts.

Based on the answer here I made a script file in Google drive and used it to successfully manipulate data in the Google sheet.

However, I want users to be able to call the script function from within the Google sheet by clicking a button. When I assign the script function name to a button in my sheet, I get "Script function testFunction could not be found" error.

Update

I have attached following script to my button:

function runTest(){
  TestScript.testFunction()
}

TestScript is the name of the standalone script project. However, I get "Reference error: TestScript not defined" when I press the button.

1
If you want to run a script from another project you’ll have to use Google app script advanced APICooper
To use the script as a library is included in your direction? developers.google.com/apps-script/guides/librariesTanaike

1 Answers

1
votes

In order to use functions from scripts that are not bounded to your Spreadsheet in your Spreadsheet script you should use libraries.

To do so, follow these steps:

  1. In your script that will run the function (i.e the script that is an outsider for your Spreadsheet as it is not bounded) go to the menu bar and select File -> Manage versions and create a new version with the title you want.

  2. Then, in the same script head over to File -> Project Properties and copy the Script ID.

  3. Go to your Spreadsheet's bounded script (this is the script that has the function that will be triggered by your button) and in the menu bar head over to Resources -> Libraries, insert the Script ID, select the latest version and give the library a name to be used locally (for example if it is set to Test you will call its functions using Test.myFunction();.

  4. Remember to assign your bounded script function to the button in the Sheet.