Auto create Option on automation script

I have a webhook that is meant to create new records on a table. Some records have new values for a singleSelect type field. I tried to create a function (code bellow) to provision new options but it fails with “Error: Cannot update field config from scripting automation”.

Without the field my await table.updateRecordAsync also fails if I pass text to this singleSelect field.

Is there any way to provision new values on a option field, to mimic the behavior of the UX where if you paste a new value it is provisioned automatically? if not, a feature request would be the passing of an option to the value of updateRecordAsync such like “create non existing values” or something.

async function updateIfNeeded(table,field,choiceName)
{
    const selectField = table.getField(field);
    if (!selectField.options.choices.find((choice) => choice.name == choiceName))
    {
        await selectField.updateOptionsAsync({
            choices: [
                ...selectField.options.choices,
                {name: choiceName},
            ],
        });
    }


}

Thanks

The “Update record” step will create new options without need for a script. Either use your script to output the record ID that needs updating or skip the script entirely if the only the the script is trying to do is modify the single select’s config options.

1 Like