Help

Re: How do you write data separately to all the records you find when you automatically find multipl

Solved
Jump to Solution
2263 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Vijay_chen
6 - Interface Innovator
6 - Interface Innovator

How do you write data separately to all the records you find when you automatically find multiple records?
the follow example find 2 records, then the next action step run fail, what can I do so that the updated action is written to each of the two records found?
automation question.png

2 Solutions

Accepted Solutions
TheTimeSavingCo
18 - Pluto
18 - Pluto

Unfortunately it's not easily doable

Third party tools like Zapier have line item support for up to ten records so you could look into that

If you want to keep it all within Airtable, a (theoretically) possible solution would be to have a "Helper" table, and when your automation runs and finds these records, you'd link them all to a single record in the "Helper" table

In the "Helper" table, you could create a rollup field that would only output the first record ID of all of the records linked to it.  You could then make an automation that would trigger when this rollup field updates, and the action would be whatever you wanted it to be (e.g. updating the record with that record ID), and you would need to make sure to unlink the record with that record ID from the "Helper" record

Doing so will force that rollup field to update and a new record ID would take its place, triggering the automation again

Should work!

 
 

See Solution in Thread

Karlstens
11 - Venus
11 - Venus

If you're able to use a Script Action within your Automation, I've detailed one way that uses both No-Code actions such as "Find Records" with a Script Action, where the Find Record acts as the input for the Script.

There are mixed advantages and disadvantages for mixing no-code and script actions together. Typically, I've found to be most comfortable coding everything in a script and not using no-code actions - but again, it can be argued either way.

Here we have a table of colours. When a new colour is added and the user checks "Run Automation", we want the Status to update with "Possible" duplicate if a name is matched on any other records.

Karlstens_1-1675891110092.png

Using the Find Records action, the following logic plays out;

The name "red" matches with "Red", "Dark red" - one of the downsides of No-Code is that you can't get very fancy with your search term and match queries. Such customisations are totally possible within a script, but we won't go into that.

The Automation is simple enough, a match trigger that triggers off of the check-box, Find Records action, and the script to update records.

Karlstens_2-1675891262538.png

Here we can see the script in action. Note how it takes the output from the Find Records as script input (an array of matching Record IDs), which feeds into the recordIds argument of the selectRecordsAsync() (and note that there's a max limit on 100 records using this technique).

Karlstens_3-1675891406399.png

const {foundRecords} = input.config();
console.log(foundRecords)

const colourTable = base.getTable("Colours")
const matchedRecords = await colourTable.selectRecordsAsync( {
  fields : ["Name", "Status"],
  recordIds : foundRecords //API limit, max 100 records.
  });

  console.log(matchedRecords)

const updateMatchedRecords = matchedRecords.records.map( record => ({
  id : record.id,
  fields : {
    "Status" : {name:"Possible Duplicate"}
  }
}));

await colourTable.updateRecordsAsync(updateMatchedRecords);
console.info(updateMatchedRecords)

The result is that upon executing this automation, any records found via Find Records will have their status updated to "Possible Duplicate".

 

See Solution in Thread

7 Replies 7
TheTimeSavingCo
18 - Pluto
18 - Pluto

Unfortunately it's not easily doable

Third party tools like Zapier have line item support for up to ten records so you could look into that

If you want to keep it all within Airtable, a (theoretically) possible solution would be to have a "Helper" table, and when your automation runs and finds these records, you'd link them all to a single record in the "Helper" table

In the "Helper" table, you could create a rollup field that would only output the first record ID of all of the records linked to it.  You could then make an automation that would trigger when this rollup field updates, and the action would be whatever you wanted it to be (e.g. updating the record with that record ID), and you would need to make sure to unlink the record with that record ID from the "Helper" record

Doing so will force that rollup field to update and a new record ID would take its place, triggering the automation again

Should work!

 
 

This setup does what I want, thank you very much!❤️

Karlstens
11 - Venus
11 - Venus

If you're able to use a Script Action within your Automation, I've detailed one way that uses both No-Code actions such as "Find Records" with a Script Action, where the Find Record acts as the input for the Script.

There are mixed advantages and disadvantages for mixing no-code and script actions together. Typically, I've found to be most comfortable coding everything in a script and not using no-code actions - but again, it can be argued either way.

Here we have a table of colours. When a new colour is added and the user checks "Run Automation", we want the Status to update with "Possible" duplicate if a name is matched on any other records.

Karlstens_1-1675891110092.png

Using the Find Records action, the following logic plays out;

The name "red" matches with "Red", "Dark red" - one of the downsides of No-Code is that you can't get very fancy with your search term and match queries. Such customisations are totally possible within a script, but we won't go into that.

The Automation is simple enough, a match trigger that triggers off of the check-box, Find Records action, and the script to update records.

Karlstens_2-1675891262538.png

Here we can see the script in action. Note how it takes the output from the Find Records as script input (an array of matching Record IDs), which feeds into the recordIds argument of the selectRecordsAsync() (and note that there's a max limit on 100 records using this technique).

Karlstens_3-1675891406399.png

const {foundRecords} = input.config();
console.log(foundRecords)

const colourTable = base.getTable("Colours")
const matchedRecords = await colourTable.selectRecordsAsync( {
  fields : ["Name", "Status"],
  recordIds : foundRecords //API limit, max 100 records.
  });

  console.log(matchedRecords)

const updateMatchedRecords = matchedRecords.records.map( record => ({
  id : record.id,
  fields : {
    "Status" : {name:"Possible Duplicate"}
  }
}));

await colourTable.updateRecordsAsync(updateMatchedRecords);
console.info(updateMatchedRecords)

The result is that upon executing this automation, any records found via Find Records will have their status updated to "Possible Duplicate".

 

The perfect way👍I guess I need to learn how to write scripts

Yup, scripts are awesome. You'll need a pro account to use them within Automations, or otherwise, you can at least write scripts in the Scripting App extension that can be manually executed.

Once you figure things out, it becomes a very addictive hobby! To get started, start to touch up on the basics of JavaScript, and then look into some example scripts that Airtable users have posted here over the years.

If you're continuing to work on this idea, do post an update. Always find these things interesting with how they evolve.

Mojjo
4 - Data Explorer
4 - Data Explorer

Hello,

I know it's an old thread but this is exactly my issue.
Is it still impossible to find 2 records and fill a table with the data separately? (not as list) 
Any updates on this would be very much appreciated! 

Hm Airtable has repeating groups in automations now which handle most cases (we can't use conditionals with it though): https://support.airtable.com/docs/repeating-groups-of-automation-actions

What're you trying to do exactly?