Add single select option & change color via script

Hi team,

I am using the scripting block to add a new single select option to a bunch of fields at once. Is there any way to specify the color of the item? Currently they all seem to be adding as grey by default.

Thanks!

Hi @Devon_Moore,
Yes, you can pass a color when creating items.
{name: string, color?: string}

Okay I had to modify this a bit, and it only takes certain color inputs, but it works! Thank you!

Dropping the code below if anybody else is looking for this in the future:

const table = base.getTable("Your Table Name");
const field = table.getField("Your Field Name");
await field.updateOptionsAsync({
    choices: [...field.options.choices, {name: "Bright Blue", color:"blueBright"}],
});

List of colors can be found here but it only accepts the Bright, Dark1, Light1, and Light2 variants since those are the available colors for dropdowns (eg. it will not accept “blue” but it accepts “blueBright”

1 Like