Skip to main content

Automation Script: changing multiple-choice data values

  • September 2, 2023
  • 2 replies
  • 32 views

Forum|alt.badge.img+2

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

Zack_S
Forum|alt.badge.img+17
  • Inspiring
  • September 2, 2023

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

Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • September 4, 2023

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.