Help on Script with Math Function

Topic Labels: Scripting extentions
677 3
Showing results for 
Search instead for 
Did you mean: 
7 - App Architect
7 - App Architect

Any idea why the math isn’t working in my script. I am expecting two numbers to be added together (2+20018 = 20020) but instead get 220018

let table = base.getTable(‘Project List’);
let queryResult = await table.selectRecordsAsync();
let record = queryResult.getRecord(queryResult.recordIds[0]);
let year = record.getCellValue(‘Year Count’)
let num = year+20018
await table.updateRecordAsync(, {“Project #”: num})

3 Replies 3

Wild guess - you’re concatenating at least one string plus a number and JavaScript is converting it all to a string.

Try using parseInt() on each value to ensure they are numbers.

7 - App Architect
7 - App Architect

That worked (BTW I know nothing of JS, I am just learning from reading the API documentation).

Now you now more than nothing. :winking_face: