menu create google apps script code example
Example: google sheet script create a cistom menu
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Custom Menu')
.addItem('First item', 'menuItem1')
.addSeparator()
.addSubMenu(ui.createMenu('Sub-menu')
.addItem('Second item', 'menuItem2'))
.addToUi();
}
function menuItem1() {
SpreadsheetApp.getUi()
.alert('You clicked the first menu item!');
}
function menuItem2() {
SpreadsheetApp.getUi()
.alert('You clicked the second menu item!');
}