Help

Re: Add single select option & change color via script

Solved
Jump to Solution
1900 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Devon_Moore
6 - Interface Innovator
6 - Interface Innovator

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
Vivid-Squid
11 - Venus
11 - Venus

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

See Solution in Thread

2 Replies 2
Vivid-Squid
11 - Venus
11 - Venus

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”