Skip to main content
Solved

How to update a multiple select field without overwriting?


Forum|alt.badge.img+13

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!

Best answer by Alyssa_Buchthal

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!

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+16
  • Inspiring
  • 532 replies
  • July 27, 2022

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'},
    ],
});

Forum|alt.badge.img+13

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!


Forum|alt.badge.img+1
  • New Participant
  • 1 reply
  • January 5, 2023

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


Forum|alt.badge.img+13
Katie_Haines wrote:

@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"}]});

Reply