- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 16, 2021 04:07 PM
I am attempting to set up an automation and have a script update a linked field in a table. When testing my script the output gives me this error. “Your script has a syntax error” (adding this for search engines cause I could not find this on google at all)
The bit of code that makes this error happen is this (it has no syntax highlighted saying it’s an error)
await customersTable.updateRecordAsync(depo, {
'Dams': dogs
})
depo
is from here
let depo = depositors.getRecord(depositors.recordIds[index])
depo
looks like this when logged: {id: "rec1231412312", name: "Some name"}
dogs
is an array of objects (“dog” records) like this.
I’m not sure where to go from here cause this error leads me nowhere. I have tried just passing an array of IDs. I’ve tried passing an array of objects with just the IDs and not the name. Nothing has worked so far. Is anyone able to tell me what I’m doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 18, 2021 08:35 AM
Do you know why it works without await but not with it? If it works without await then the data/data structure can’t be the issue. I’m pretty sure it’s an airtable quirk because I’ve done this in other javascript applications.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 18, 2021 09:28 AM
You can use await inside a loop, and inside an anonymous function. You just have to declare the function as an async function.
puppyAvailability.forEach(async (dogs, index) => {
On the other hand, even though this is possible to use await inside the loop, it is better to update the records in bulk after the loop.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 18, 2021 09:58 AM
Ok, I can’t believe I forgot to mark my function in my loop as async. You’re right about updating them in bulk, but I have over 50 records that need to update so I still have to update within the loop, but I currently have it set up to update the max allowed records at a time on each iteration. Thank you.
I might also mention that I needed to change the way I looped since the await doesn’t run in a forEach. I changed it to a for of loop and wrapped it in an async function. Now everything is working as expected.

- « Previous
-
- 1
- 2
- Next »