'Google Sheets - Script function could not be found

I am working to link an image in my Google Sheet document to a specific cell in another tab. I'm doing this by building a simple function that will do this. However, when I assign the function and then click on the image, I then get the error "Script function "test" could not be found". When I run the function in the script manager interface, it works fine. It's when I try to actually use it in the sheet with the image.

Function Script:

function test()
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("TX Marketing Data");
  sheet.setActiveRange(sheet.getRange("A91"));
};

enter image description here

Steps to recreate:
1) Create image
2) Go to image, right click, go to drop down and select "Assign Script"
3) Enter "test" as the assign script



Solution 1:[1]

Remove ";" at the end of your function (after }).

Solution 2:[2]

Had a similar problem and just solved it.

When assigning a script function to a button make sure to call the specific function name(i.e. "getWeatherData") and not the App Script name (i.e. "WeatherAPI").

Solution 3:[3]

Another thing that can happen is that you have a library that has the same name as the function. For example you have imported a library that to refer to "test" in your code. If you name your function

function test(){
   your code
}

Then you will get the same error that you got. visual example of library with same name of a function

Solution 4:[4]

Try reloading the page.

Sounds like a simple 'turn it off and on again' fix but after having the same issue and trying to save a new version, renaming the function, creating new function etc. a page reload was all it took!

Solution 5:[5]

I had exactly the same problem. Eventually I found the problem when I looked at the script Function name, which should be Function followed by the name you gave the script when it was created. when creating file names sometimes you are not able to use special characters which is what I had done. Once I gave it a name that had allowable characters there was no problem. In programming when you call a function that does not match the name given to the function or procedure you will end up getting the error function not found.

Solution 6:[6]

I had the exact same issue, when I used submitdata , after I changed it to submitData it said it submitdata was deleted. so i put it back to original form and bam!! fixed.

Solution 7:[7]

Same issue, but much dumber reason for me.

So, here is my answer: Make sure to hit the "Save" button in Apps Script.

I was so used to all the other google apps automatically saving/syncing I didn't realize that I actually had to hit "Save" on the scripts. I caught it when I noticed the function I was trying to run wasn't appearing in the list of functions to run in Apps Script. Once it hit save, the name of the function appeared in the list AND clicking my button ran it successfully from the sheet.

Solution 8:[8]

You should call your function name, not the script itself. If your function is called myFunction() you should write myFunction. And be careful to rename your function to something that isn't already in your library

Solution 9:[9]

Ran into the same issue but solved it by renaming it with a prefix, executing it in Sheets and then renaming it back without the prefix.

function calculateSomething() {
  return 10;
}

To

function prefixCalculateSomething() {
  return 10;
}

Update the Sheet with the new name, it should work now. Now rename it back.

function calculateSomething() {
  return 10;
}

Update the Sheet with the original name, and it should still work. Maybe a refresh would've worked as well but that's not how I solved it.

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 Amir
Solution 2 Aaron Alex Vargas
Solution 3 Mathieu
Solution 4 Ben Kammerling
Solution 5 Travis
Solution 6 Joe
Solution 7 Trashman
Solution 8 FranciscoSilva
Solution 9 Nate-Wilkins