Jul 27, 2022 10:57 AM
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!
Solved! Go to Solution.
Jul 27, 2022 12:24 PM
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!
Jul 27, 2022 12:07 PM
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'},
],
});
Jul 27, 2022 12:24 PM
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!
Jan 04, 2023 04:34 PM
@Alyssa_Buchthal Are you able to share how you did that?
Jan 05, 2023 06:59 AM
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"}]});