Updating a field when I don't know the name

Topic Labels: API
1038 1
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

I have 20 fields in my table that are named ACH001, ACH002, ACH003, etc. (They’re achievements for a game.)

I want to update a specific field when a user completes the achievement, but I don’t know which one they’re completing until I’m ready to make the update call to the database. So, I’m creating a variable called “fieldName” that contains the name of the field. This doesn’t seem to work, however. I get an UNKNOWN_FIELD_NAME error. Error 422. Anyone have any tips on how I should approach this one?

var fieldName = getFieldName(achievementId);
var airtable = await new Airtable({apiKey: process.env.airtable_key}).base(“appx5AkeU3qgwlYDn”);
airtable(‘User’).update(UserRecord.RecordId, {
}, function(err, record) {
if (err) { console.error(err); return; }

1 Reply 1
5 - Automation Enthusiast
5 - Automation Enthusiast

Figured it out. Just needed to wrap fieldName in brackets, like this: