Help

Re: How to update a multiple select field without overwriting?

Solved
Jump to Solution
1627 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Alyssa_Buchthal
7 - App Architect
7 - App Architect

I have a multiple select field I am attempting to update within an automation, but I can’t seem to add an option to it without overwriting. Pared down, this is essentially what my code looks like right now:

Val = record.getCellValue("The Cell")
if(conditions met) {
    await table.updateRecordAsync(record.id, {"The Cell": [Val, {name: "NewVal"}]});
 }

And this isn’t working, as it says it can’t recognize this input type. I’ve also tried using getCellValueAsString and then passing that as another option, but that didn’t work either. Right now the code is working but is overwriting the cell value when it does, so I want to add this functionality where it doesn’t overwrite. Any help appreciated!

1 Solution

Accepted Solutions
Alyssa_Buchthal
7 - App Architect
7 - App Architect

I’m not trying to update the options, I’m trying to update the actual content of the field. Nothing for it in the documentation, but I did end up solving the issue by needing to reference the index and .name of the original field values, then I could pass them in as arguments. All fixed now!

See Solution in Thread

4 Replies 4

Hi @Alyssa_Buchthal,
Here is a snippet from the documentation that shows how to add an item and retain the existing items.

const selectField = table.getField('My select field');
await selectField.updateOptionsAsync({
    choices: [
        ...selectField.options.choices,
        {name: 'My new choice'},
    ],
});
Alyssa_Buchthal
7 - App Architect
7 - App Architect

I’m not trying to update the options, I’m trying to update the actual content of the field. Nothing for it in the documentation, but I did end up solving the issue by needing to reference the index and .name of the original field values, then I could pass them in as arguments. All fixed now!

Katie_Haines
4 - Data Explorer
4 - Data Explorer

@Alyssa_Buchthal Are you able to share how you did that?

yeah totally @Katie_Haines !

I will say that my solution is limited to when the multi-select field has only 1 argument already entered, you'd likely need to use a switch statement or loop to handle multiple, but the field update ended up looking like this:

await table.updateRecordAsync(record.id, {"Field Name": [{name: ExistingFieldValues[0].name}, {name: "New Field Value to Add"}]});