Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Feb 03, 2022 12:49 PM
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
Solved! Go to Solution.
Feb 03, 2022 04:50 PM
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);
Feb 03, 2022 04:50 PM
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);
Feb 04, 2022 08:07 AM
Beautiful. Thanks @Justin_Barrett!