Scripting - update variable value using a 'number' from a single select field

Hello, new to scripting, running into an issue on a single line as I hack my way through. Just trying to update script var “totes” to be 10 times the value recorded from the single select field “Pts this week”.
So if “Pts this week” has a value of 7, the script var totes should be 70 after this line is what I am trying to accomplish.

The line below gives me NAN so I’m doing something wrong on this particular line. If I am not mistaken, NUMBER() should do the trick as the single select value of 7 will be a string if taken as is.

Anyway, here is the line. Any help is appreciated.

totes = 10 * Number(record.getCellValue("Pts this week"));

Thanks in advance

I’m afraid that you are mistaken on that point. When using getCellValue to query a single-select field, the return isn’t a string. It’s an object containing properties about the selected item (name, ID, and color). To get the value as a string, use getCellValueAsString.

totes = 10 * Number(record.getCellValueAsString("Pts this week"));

Alternately, you could use getCellValue and then get the name property from the returned object:

totes = 10 * Number(record.getCellValue("Pts this week").name);
1 Like

Beautiful. Thanks @Justin_Barrett!

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