Skip to main content
Solved

Need help passing a variable for the field name with updateRecordAsync

  • November 23, 2021
  • 2 replies
  • 19 views

This is killing me. It’s literally the last speedbump in my first Airtable script:

I have this command:

await email.updateRecordAsync(dateArray[i][0],{‘ActualFieldName’ : linkID});

It works! But THIS…

await email.updateRecordAsync(dateArray[i][0],{fieldVar : linkID});

DOESN’T WORK. Even with the single-quotes gone, the system is still parsing my defined and assigned fieldVar as the string “fieldVar”.

It’s maddening. Any ideas?

Best answer by Justin_Barrett

Wrap square braces around the variable that contains the field name.

await email.updateRecordAsync(dateArray[i][0],{[fieldVar] : linkID});

2 replies

Justin_Barrett
Forum|alt.badge.img+21
  • Inspiring
  • 4647 replies
  • Answer
  • November 23, 2021

Wrap square braces around the variable that contains the field name.

await email.updateRecordAsync(dateArray[i][0],{[fieldVar] : linkID});

  • Author
  • New Participant
  • 2 replies
  • November 23, 2021

Wrap square braces around the variable that contains the field name.

await email.updateRecordAsync(dateArray[i][0],{[fieldVar] : linkID});

I love you.

That worked.