Update number fields using JS?

Topic Labels: API
3014 4
Showing results for 
Search instead for 
Did you mean: 
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:
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; }\

eval (updatestr);
4 Replies 4
4 - Data Explorer
4 - Data Explorer

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

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