Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Add single select option & change color via script

Topic Labels: Scripting extentions
Solved
Jump to Solution
301 2
cancel
Showing results for 
Search instead for 
Did you mean: 

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!

1 Solution

Accepted Solutions

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

See Solution in Thread

2 Replies 2

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”