Sep 02, 2023 04:43 AM
Hey Everyone, Can anyone spot where I'm going wrong here?!
I am trying to add multiple values to a multiple-choice field:
const YesVotes = ["Adam", "Bob", "Charlie"];
const YesArray = [];
for (var i = 0; i < YesVotes.length; i++) {
YesArray.push('{name: ' + YesVotes[i] + '}');
}
console.log(YesArray);
So the console log is giving me what I think I want:
["{name: Adam}", "{name: Bob}", "{name: Charlie}"]
But the function
output.set('YES Votes', YesArray);
Is not making the change to the YES Votes column of my table.
Sep 02, 2023 05:54 AM
Hi @ssdata - Here's documentation on multiple selects https://airtable.com/developers/scripting/api/cell_values#multiple-selects
This works to update options within the field (column)
let table = base.getTable("YOUR TABLE NAME");
const multipleSelectField = table.getField('YES Votes');
await multipleSelectField.updateOptionsAsync({
choices: [
...multipleSelectField.options.choices,
{name: 'My new choice'},
],
});
Sep 03, 2023 06:13 PM
Hi,
the command output.set(varname, value) does not change data in table and setup for field. It just pass value as step output, which you can use in further steps.