Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Feb 16, 2023 04:21 AM
What are the acceptable colour choices for single/multi selects in scripting?
I've been creating new fields via a script and now I want to make a multi and single select, which is fine, I can do that much like so:
await table.createFieldAsync("new", "multipleSelects", {choices:[{name:"test"}]});
But all the colours become grey and I'd like to specify the colour of the tag (or randomise it). I know there's a `colour` option for the array, but the documentation doesn't specify or give examples of what this should look like other than it being a string.
I've tried using hex codes for colours, colour names etc., even the specific colour code of the default colours I can use, but I'm always getting this error message:
j: Can't create field: invalid field config. Failed schema validation: <root>.options.choices.0.color does not match one of the possible values
But I can't see anywhere that tells me what any of the "possible values" are!
Can anyone help?
Thanks
Solved! Go to Solution.
Feb 16, 2023 10:01 AM
Hi,
use output.inspect (or console.log, idk the difference) to search different objects. get any table with colored selection and expand output schema
output.inspect(base.getTable('TABLENAME').fields)
this code piece will display all colors and their unique set for a given table
const flds=base.getTable('TABLENAME').fields.filter(f=>f.options?.choices)
const getColors=flds.flatMap(f=>f.options.choices.map(c=>c.color))
output.inspect(getColors)
output.inspect(Array.from(new Set(getColors)))
Feb 16, 2023 10:01 AM
Hi,
use output.inspect (or console.log, idk the difference) to search different objects. get any table with colored selection and expand output schema
output.inspect(base.getTable('TABLENAME').fields)
this code piece will display all colors and their unique set for a given table
const flds=base.getTable('TABLENAME').fields.filter(f=>f.options?.choices)
const getColors=flds.flatMap(f=>f.options.choices.map(c=>c.color))
output.inspect(getColors)
output.inspect(Array.from(new Set(getColors)))
Feb 17, 2023 03:16 AM
This is great, thanks! Really this (or the output) should be in the documentation.
For reference to anyone else searching this, here's the default colours:
0: "blueLight2"
1: "cyanLight2"
2: "tealLight2"
3: "greenLight2"
4: "yellowLight2"
5: "orangeLight2"
6: "redLight2"
7: "pinkLight2"
8: "purpleLight2"
9: "grayLight2"