Help

Re: How to get ONE record from "Find records" step?

6681 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Kamil_Lelonek
5 - Automation Enthusiast
5 - Automation Enthusiast

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.

10 Replies 10

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.

Kamil_Lelonek
5 - Automation Enthusiast
5 - Automation Enthusiast

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?

Yes, a scripting step.

Are you doing this with linked records? Is there any chance of making the email field the primary field of Table B?

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.

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:

  1. Convert Table A’s email field into a Link to Another Record field pointing to Table B.
  2. Keep Table A’s email field the same and add a new field for the Link to Another Record pointing to Table B.

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.

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.

sistemas_urbita
6 - Interface Innovator
6 - Interface Innovator

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.

Nora_Brown
6 - Interface Innovator
6 - Interface Innovator

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:

 

Screen Shot 2024-03-07 at 3.37.21 PM.png

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);

 

 
You can then use the output in your next step (an Update Record step for example).