How to match / write into a single-select field?

Hi - I have a newbie question here. I am writing a script with the script block to write a value into a single select field but I keep bashing my head against the wall. Can someone give me some guidance?

Here’s the short and skinny:

If I use the below, it all works, because the “ZIP CODE” field is of type “single line text”. I can write “12345” into it all day long.

 let newPreference = "12345";
// update the notes history value and reset the notes value
VoterTable.updateRecordAsync(record, {
    "ZIP CODE": newPreference
}) 

However, in the below, the “PARTY” field is of type “single-select”. One of the options is “Green” but I cannot write “Green” into the field at all. In fact, I cannot write ANY of the options into the field at all. I tried prepending the ordinal value as “11Green” and “11|Green” (Green is the 11th value) and nothing works. Every time I run this, nothing happens.

 let newPreference = "Green";
// update the notes history value and reset the notes value
VoterTable.updateRecordAsync(record, {
    "PARTY": newPreference
})

Any help for a newbie is appreciated … thanks.

Welcome to the community, @aalj! :smiley: The syntax for updating a single-select field isn’t terribly intuitive. There are actually multiple ways to do it, but here’s how to pull it off using the text of the item you want to select:

let newPreference = "Green";
// update the notes history value and reset the notes value
VoterTable.updateRecordAsync(record, {
    "PARTY": {name: newPreference}
})

Thank you that works! You are right, the documentation for that syntax is pretty much non-existent, at least with the first 5 pages of Goog search that I did. :slight_smile:

Google definitely won’t help you. You need to know what’s expected by the scripting block API, and that’s actually documented in the API itself, at the bottom of the editor. I actually found the hint in the popup annotation while testing the code, but if you look in the “Cell values & field options” section of the API docs, you’ll find it there as well.

If you would, please mark my answer above as the solution to your question. This helps others who may be searching with similar questions. Thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.