I’m experimenting with using AI to extract structured data from a PDF document and create records from it. The example is a price list with 3 columns: Part number, description, price. I copy and paste the text into a long text field. An AI automation action can take that text and turn it into an array of values. I’d like to then use a repeating group to create a record for each of those Parts. What format is needed for Airtable to recognize the array as an input list?
For the input list of a repeating group in an Airtable automation, Airtable only supports 4 types of inputs:
- The result of the “Find Records” action.
- A user field that is set to allow multiple users.
- A linked record field that is set to allow multiple linked records.
- Script output that is in an array format.
Thank you @ScottWorld! I suppose I can process the results through a script. Side note - I just learned recently that rollups can also be used as an input list
Wow, rollups too? Thats good to know! Airtable should update their support article on this topic!
They should! An update on my repeating group project: I was able to take JSON output from the AI action, use it as input for a script, then convert it to an array using JSON.parse()
From there, I was having an issue with Airtable recognizing the output when used as “current item” in a repeating group, getting an error message that said “Cannot assign union of object to collection of complex types”. Airtable support told me that this kind of error shows for an array of objects when a property can contain multiple data types. In my case, “Price” was usually a number but sometimes text. When I made sure it always output text, the repeating group worked.
The whole script looked like this:
const listOutput = input.config().list
const listPrices = JSON.parse(listOutput,
(key, value) =>
typeof value === "number"
? "value" // return string value for numbers
: value, // return everything else unchanged
);
output.set("List Prices", listPrices)
That said, it turned out that once the list was in a script, it was just as easy to create the repeating action with the script, and I made another version that did that instead - using the script to loop through records seemed to execute faster in this case. But it’s still nice to have the repeating groups as an option!
Does it depend on the rollup formula? Sometimes rollup values are lists and sometimes they are not, depending on the formula. For example, I would expect ARRAYCOMPACT(values)
to return a list, but I would expect ARRAYJOIN(values)
to not be a list.
I find that updating records in a script is much faster than updating them in an update records action. However, I currently lean towards having the script output a list and then using a repeating action group with an update records action instead. Even though the execution time is slower and there are more actions in the automation, the overall system is less fragile: fewer hardcoded the field names or IDs in the script, and the automation shows up in the dependency checker.
Probably it does. In the case that I saw, the fomula used was ARRAYUNIQUE(values)
This is a huge plus