I'm creating a dynamic custom menu from REST call in google spreadsheet. With every call I receive different sports that I want to use as menu items
// sample sports array
var menuItemsArr = ['Footbal', 'Tennis', 'Swimming'];
var menu = SpreadsheetApp.getUi().createMenu("Sports");
for (i in menuItemsArr){
menu.addItem(menuItemsArr[i],'createSheet')
.addSeparator()
}
menu.addToUi();
When the user clicks on menu item I want to create a new sheet with title - the sport that was clicked. So if the user choose Tennis I want to create a sheet with name Tennis.
Is it possible to know which menu item was clicked (to take the name of the item (Tennis) somehow, or at least the index of the menu item that was clicked?
Any help will be appreciated! Thanks.