Help on Script with Math Function

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

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.


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

Now you now more than nothing. :wink:

1 Like