Help

Updating the choices from a singleSelect

50 1
cancel
Showing results for 
Search instead for 
Did you mean: 
amadeus
4 - Data Explorer
4 - Data Explorer

Hi, 

I want to update the choices a singleSelect field has without adding a new record.

I tried this approach, but that yields the following error

TypeError: Cannot add property 2, object is not extensible

Here is the relevant code (MtypeName gets its value from a singleLineText field)

let MtypeName = Mtype.getCellValueAsString("Meeting Type")
let Types = MeetingsTable.getField("Meeting Type")
Types.options.choices.push({name: MtypeName})
 
I this possible without residing to API calls?

If this is only possible using the Rest API, I suppose I cannot use this without providing the authentication details, right ?
1 Reply 1

You can do this via the Scripting Extension: https://airtable.com/developers/scripting/api/field#update-options-async

const table = base.getTable("Tasks");
const selectField = table.getField("Priority");
await selectField.updateOptionsAsync({
    choices: [...field.options.choices, {name: "Urgent"}],
});

If you want this to be part of an automation you'd need to do it via the API like you said though, and you'd need to auth