Help

Re: Update number fields using JS?

843 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Oren_Levine
4 - Data Explorer
4 - Data Explorer

I’m writing a simple resource management application, where staffers enter for each month the percent of their time they spend on various projects. I store those allocations as "percent’ fields in an Airtable table.
I collect inputs for these from a node.js web page, and want to update the allocations in the database.

When I pass the values to the update() function, I see the following:
error: ‘INVALID_VALUE_FOR_COLUMN’,
message: ‘Field May 17 can not accept value 15’,

I suspect that the system is seeing string values instead of the required number values, but don’t know how to deliver the correct format from JS.
I’ve tried the value with and without quotes, and also tried submitting parseInt(value).

Note: I’m also using eval() to generate the update() command, as my function handles the update field names as variables, which also seem to be a problem

// build the update string
var updatestr = "base(\'allocations\').update(\'" + request.body[i].allocid + "\', {";
updatestr += "\"" + request.body[i].month + "\":[" + request.body[i].pct + "]";
updatestr += "}, function(err, record) {  \
		if (err) { console.log(err); return; }\
		console.log(record);\
    });";

console.log(updatestr);
eval (updatestr);
4 Replies 4
Oren_Levine
4 - Data Explorer
4 - Data Explorer

Please disregard the above. Turns out to be my error, not the API. Apologies for that.

Brendan_Norris
4 - Data Explorer
4 - Data Explorer

What did you end up doing to fix this? I’m getting the same error.

I also work with airtable on many projects.

Sometime i have this error for numeric values, i fixed it by setting field type to “Single line text”.

Can you please tell me how did you solved it? Thanks