Reputation: 121
Here is my code. Ir runs fine from Debug and from Run in the code ui, but when running from the press of a custom menu button I get this error:
Script function not found:
function menuItem1() { var ui = SpreadsheetApp.getUi(); ui.alert("Hello There"); }
Here is my code:
function menuItem1(){
var ui = SpreadsheetApp.getUi();
ui.alert('Hello There');
}
That is it!
I have other sheets that have tons of code that do all kinds of craziness with spreadsheets and and even form creation.
Cant figure out why I am getting this. It doesn't matter code I put into this function either. I get a listing of the entire code in an error detail form presented as a dialog over the spreadsheet.
Anyone?
Upvotes: 3
Views: 6459
Reputation: 121
What a dummy I am. Must be staring at the screen too long!
The code was fine. It was the creating of the custom menu item that was BROKE!!
function myFunction() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('League Wheelhouse Menu')
.addItem('Create League Forms', 'menuItem1')
.addToUi();
}
I forgot to ' ' around the name of the function. Of course my code is tons longer than the code above, but since it was throwing this crazy error I decided to replace the code with something crazy easy to try and find the issue.
Could not find it with crazy easy so I started a new project. When I created the menu creator I put the ' ' around the function name as I typed. BAMM... SLAM... KAPOW... that is when it hit me.
I bit surprised that when you save the file it does not throw a compiling error.
All fixed.... so dont forget when you put in a custom menu item.. put your name in AS TEXT!!! 'HappyProgramming'
Upvotes: 4