Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

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

Topic Labels: Extensions
Solved
Jump to Solution
903 2
cancel
Showing results for 
Search instead for 
Did you mean: 

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

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

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