Help

Automation Script: changing multiple-choice data values

506 2
cancel
Showing results for 
Search instead for 
Did you mean: 
ssdata
4 - Data Explorer
4 - Data Explorer

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.

2 Replies 2
Zack_S
8 - Airtable Astronomer
8 - Airtable Astronomer

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'},
    ],
});


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.