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?
Solved! Go to Solution.
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.
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
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?
Yes, the record is created as soon as the empty row appears (or very shortly afterwards). A couple of ways around this:
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