Nov 14, 2021 12:04 PM
Is there a way to fetch just one record or take the first/last one from the returned list?
In table A I have a record with an email.
In table B, I also have records with their emails.
I need to update A record with B attributes but they come from different sources and are not associated - they just have the same emails.
Nov 14, 2021 12:50 PM
Unfortunately, there is no native built-in way to do that with automations, so you would need to find a different way of doing it.
You could write a custom JavaScript, or you could use an automation tool like Integromat which lets you limit your searches to 1 found record, and also lets you filter your search results, sort your search results, aggregate your search results, iterate through your search results, and more.
There might even be a better way of structuring your entire base so that you don’t need to use automations to do it at all.
Nov 15, 2021 01:28 AM
Uh… I have two data sources that put the data in different tables. The only way to associate them then is via email.
By a custom JS code you mean a scripting step?
Nov 15, 2021 03:19 AM
Yes, a scripting step.
Nov 15, 2021 07:29 AM
Are you doing this with linked records? Is there any chance of making the email field the primary field of Table B?
Nov 15, 2021 08:57 AM
Are you doing this with linked records?
Unfortunately not, they come from different sources.
Is there any chance of making the email field the primary field of Table B?
Yes, I think so.
Nov 15, 2021 09:09 AM
The origin of the records should not affect whether or not you can link them together.
If the primary field of Table B is the email then you can do one of two things:
Option 1 means you won’t need any automations at all, Option 2 means you could use a simple Update Record step in an automation to copy a Table A record’s {Email}
value into the {Link to Table B}
field (no script required).
Once you’ve done either 1 or 2, then add add Lookup fields to Table A to bring in Table B’s values.
Nov 15, 2021 02:24 PM
Email in table A is actually already a lookup from another table.
In Option 2 the issue is that a record in table B appears later than the record in table A. It means I cannot automate the update of table A since there is no corresponding record in table B yet.
Apr 07, 2023 06:08 AM
I managed to get the ONE record in automation by adding a repeating group. It will iterate over the results and perform some actions, but because I guarantee the found records list contains only one result (I searched by record ID), it will perform the action exclusively on said record.
Mar 07, 2024 12:46 PM - edited Mar 07, 2024 12:47 PM
While Airtable Automation's Update Record action doesn't seem to mind if you put a list of length 1 in, for example a number field, instead of just the number, it is pretty easy to add a script step to just return a single value from the Find Records step. After you add a Script Step, add an input value that will be made available to the script:
Use whatever name you want and then select either the list of record ids or the list of specific field values. Then, in your script:
let scriptConfig = input.config(); // can only be called once
let firstRecord = scriptConfig.foundRecords.length > 0 ? scriptConfig.foundRecords[0] : null;
output.set('firstFoundRecord', firstRecord);
Mar 13, 2024 06:58 AM
I'm trying to do something similar with automation here, but I'm getting stuck in the Update Record step. I'm using the "Find Records" function to gather available options but am having trouble selecting just one and then inserting it into another record in a different table.
In case it's helpful, this is my issue: https://community.airtable.com/t5/automations/automation-updating-record-with-just-one-item-from-ano...