Skip to main content
Solved

Updating the choices from a singleSelect

  • December 1, 2024
  • 1 reply
  • 2 views

Forum|alt.badge.img+3

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 ?

Best answer by TheTimeSavingCo

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

View original
Did this topic help you find an answer to your question?

1 reply

TheTimeSavingCo
Forum|alt.badge.img+28

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


Reply