Help

Use string variable for table.updateRecordAsync

Topic Labels: Scripting extentions
Solved
Jump to Solution
1537 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Noah_Coleman
6 - Interface Innovator
6 - Interface Innovator

Is there a way to tell table.updateRecordAsync what field to update with a variable? I have a table that tracks the date a person receives multiple trainings. Each training has a date field. I’m able to hard code the field in table.updateRecordAsync, but I haven’t figured out a way to do it with a variable, even a string type variable. This would allow me to have one script where one could select the training to update, rather than a script for each training. Here is my code:

await recordTable.updateRecordAsync(record,{
    '*INSERT VARIABLE HERE': date
});

I also tried using the usual javascript way of inserting variables into strings like this:

await recordTable.updateRecordAsync(record,{
    `${fieldString}`: date
});

This just gives me lots of errors.

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto
await recordTable.updateRecordAsync(record,{
    [fieldString]: date
});

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto
await recordTable.updateRecordAsync(record,{
    [fieldString]: date
});
Noah_Coleman
6 - Interface Innovator
6 - Interface Innovator

Thanks, @kuovonne! That did the trick!