Is there an ID for MultiSelect options and Single Select?

I am trying to develop a script with a mutli-select option. Is there a code for each of these so if I choose to change the actual name, it won’t be a problem?

Hi @Rose_Haft1 - Single and Multi-select fields have a similar structure. A single select is an object of id, name and colour. Multi-select is an array of these objects:

You can reference the select value or values by the id rather than the name and if the name is changed the id will remain the same. When creating or updating a single select field you can write to is using the id or the name:

So, as you want to do, if you go for the id option here you will be fine.

2 Likes

Thanks. That is great. Do you have a sample of how I would reference these with script? I have not been able to figure this out…

@Rose_Haft1 - if I have two single select fields like this:

Then this script will get the values of each value in the first field, then updates the second field with its value:

let table = base.getTable('Table 1');
let query = await table.selectRecordsAsync();

// read the values
for (let record of query.records) {
    let id = record.getCellValue('Single Select').id;
    let name = record.getCellValue('Single Select').name;
    let color = record.getCellValue('Single Select').color;

    // read/log the values
    console.log(id, name, color)

    // write the values
    table.updateRecordAsync(record, {
        'Single Select 2': {id: id}
        // or:
        // 'Single Select 2': {name: name}
    })
}

It is similar for a multi-select, but you would have to iterate over each value within the field:

record.getCellValue('Multi Select')