I try to add some names from array to list dropdown not work.
This is my code:
function dataDrpdwon() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var item = ss.addListItem();
item.setTitle('Do you prefer cats or dogs?')
.setChoices([
item.createChoice('Cats'),
item.createChoice('Dogs')
]);
}
after add =dataDrpdwon() in any cell I see this error TypeError: ss.addListItem is not a function (line 3). any help to fix.
I want to add =dataDrpdwon() in any cell and see List dropdown.
addListItem is a function in ListItem Class.
Here documentation https://developers.google.com/apps-script/reference/forms/list-item
addListItem is not available for on the ActiveSpreadsheet object, I think it's only available for Forms.
I'm not overly familiar with App Script, but drop downs within Sheets/Excel are typically done via validation. So you may need a different approach. A quick search found this that might put you in the right direction.