Henri PETERS
Henri PETERS

Reputation: 31

Button doesn't work on google spreadsheet

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() 
{ 
    Browser.msgBox("You clicked it!"); 
}

It turned out that the document owner had left their job and ownership rights had been moved to someone else. Can it matter ? The error is : Here

Thank you very much,

Upvotes: 1

Views: 2970

Answers (2)

Bitey
Bitey

Reputation: 59

Make sure the assigned function name does not include the () brackets. 😎

Upvotes: 1

ReyAnthonyRenacia
ReyAnthonyRenacia

Reputation: 17621

Did a little snippet just to demonstrate on how you might approach this:

I used the sample from HTML Service: Create and Serve HTML on creating a button (in your case it's image) which responds to a click event. I'm using a bound script.

//in bounds script, this integral function triggers as soon as you open the spreadsheet
function onOpen() {
  SpreadsheetApp.getUi() 
      .createMenu('Dialog')
      .addItem('Click Me', 'test')
      .addToUi();
}

//Then I attached your test function
function test() 
{ 
    Browser.msgBox("You clicked it!"); 
}

And sure enough upon clicking the button, the test function triggered:

enter image description here

Upvotes: 0

Related Questions