Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Using a variable for field name in updateRecordAsync method

Topic Labels: Scripting extentions
Solved
Jump to Solution
297 2
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi there!

I’m not a developer but I trying to write a script.
Please tell me if is possible to use a variable to define the field name inside updateRecordAsync method.

await table.updateRecordAsync(record, {"Phone": value})

the method accepts variables for “record” and for field “value”

but I want to use a variable for “Phone” (without quote marks) like the example below:

let fieldName = "Phone";
await table.updateRecordAsync(record, {fieldName: value});

I want to let users set up fieldName using input.config

Please help. :pray:

1 Solution

Accepted Solutions

Hi,

use such syntax for that:
await table.updateRecordAsync(record, {[fieldName]: value});

See Solution in Thread

2 Replies 2

Hi,

use such syntax for that:
await table.updateRecordAsync(record, {[fieldName]: value});

Thanks, Alexey! I appreciate it