
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 03, 2022 07:06 AM
Hi there,
I have built an automation that will:
Step 1: Trigger when a record is created in Table A
Step 2: Find matching records based on a condition in Table B
Step 3: Update a linked field on all matching records from Step 2 with the ID of the new record from Step 1
For Step 3 I have written a script as I understand the “update record” feature can’t handle multiple records.
The script isn’t producing any errors however it isn’t working. It should update the field “Applicant Record” with the record ID from Table A - at the moment nothing is being added.
Would you be able to help check if I’ve made a mistake with my code?
Cheers!
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 06, 2022 04:27 AM
Hi @Michael_Benson you can use console.log
so something like:
for (let record of enquirerRecords) {
console.log(record}
}
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 05, 2022 06:30 AM
In your for
loop, start by logging record
. This might not be in the right format for the updateRecordAsync
method. You can pass in a record id or a record from a query result, but I wonder if the list of records is giving you something completely different.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 05, 2022 09:51 AM
Thanks Jonathan - this is a newbie question, but how should I go about logging record? Should I be using the output
object? Any help getting started here would be great!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 05, 2022 10:24 PM
Hi,
i think you can achieve your goal without script, via usual ‘Update record’ step
you can’t update multiple records, but you can update a single record that triggered automation (step 1), by putting a result of step 2 into it’s linked field.
but anyway, you might want to debug your script and understand why it isn’t working. comment your ‘await enquirerTable…’ command and put console.log(record) and/or console.log(applicantID) near it to check what’s happening
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 06, 2022 04:27 AM
Hi @Michael_Benson you can use console.log
so something like:
for (let record of enquirerRecords) {
console.log(record}
}

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 06, 2022 05:01 AM
Thanks guys. I think I’ve worked out the problem.
It seems the script is triggering too quickly. It is set to trigger when a new record is created, but sometimes a user might create a record and then spent 5-10 seconds filling out the fields that this script would use to find a match in Table B.
The script is triggering before those fields are filled out, therefore it isn’t finding any matches and is failing.
What is the best practice here to setup a trigger that fires when a) a new record is created, and b) a specific field on that new record is filled out?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 06, 2022 12:57 PM
Yes, the record is created as soon as the empty row appears (or very shortly afterwards). A couple of ways around this:
- Always create the record with an Airtable form. This ensures that all of the relevant fields are populated on creation.
- I sometimes define a formula field that works out if key fields have been populated. It returns zero if they haven’t and 1 if they have. You can then trigger your automation on “when record meets conditions” - namely that this field is 1. You could make the conditions explicit on the key fields, but I find the formula method a bit easier to manage if there are lots of mandatory fields.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 06, 2022 05:18 PM
If the user is completing the data entry in the Airtable, consider running the script from a button instead of the automation. This way the user doing the data entry can click the button as soon as the data entry is done.
Using Scripting app instead of an automation will
- free up an automation slot
- not use up automation runs
- give the user control over exactly when the script runs with regard to data entry being complete
- allow the script to provide feedback if there is an issue with the inputs
- allow you to use script settings so that the script will still work if table or field names change
