Help

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

Solved
Jump to Solution
794 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Kaleb_Penner1
5 - Automation Enthusiast
5 - Automation Enthusiast

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

1 Solution

Accepted Solutions
Justin_Barrett
18 - Pluto
18 - Pluto

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);

See Solution in Thread

2 Replies 2
Justin_Barrett
18 - Pluto
18 - Pluto

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);

Beautiful. Thanks @Justin_Barrett!