How to set multiple Airtable linked records?

In this branch, the “Parse JSON” module plucks a Long Text field containing a pre-JSON string, in the format…

{
   "people":[
      {
         "name":"Bill Gates",
         "title":"Chairman",
         "company":"Microsoft",
         "role":"speaker"
      },
      {
         "name":"Dan Rather",
         "title":"Anchor",
         "company":"CBS News",
         "role":"interviewer"
      }
   ]
}

There will always be multiple people - there may be multiple speakers, usually only one interviewer. For all those found, I want to search for and create/update (Upsert) them.

Assume 4 speakers and 1 interviewer.

Then (and this is the key) I want to set these as linked records in one of two fields of the starting Airtable record, depending on their role.

In the below, I’ve basically done this fine. However, when it comes to the Router path filtered for acting on role “speaker”, is is Updating the starting record four times and overwriting the linked record, rather than adding all four to it once.

I guess that’s because I’m using the Iterator to do “For each person”.

Does anyone have a better way of doing this, please?

Sure there is a better way to do this.

After you create the new or update the new person use an array aggregator and aggregate the IDs that you created or upserted

Then you can map the ids into the linking.
From the looks of it you will need to also aggregate the type of person then filter the mapping based on the type (basically what your filters do)

@Mr.Make

1. This just results in four separate bundles, rather than a combined one.

Using a Set Variable to test a map, I still don’t see this combining the rec IDs…

Still unsure how to set multiple records in a linked record field…

{{map(; 461.array[].id; "id")}} in the Airtable field gets sent as empty.

  1. FYI, the person’s “role” is sourced in the earlier JSON and not in their Airtable record (though I do see it’s possible to combine fields from two modules in an array aggregation).

@Mr.Make

I think it’s leading to four separate bundles because of the upstream Iterator I used to pluck four people out of the JSON object’s “people” node (which is its only parent node)…


(This is necessary because the JSON object contains the people we’re looking for in Airtable. When we Upsert them to the People table, we then want to set them in the Assignments table in either the Speakers or Interviewer linked-record fields.)

But things are getting executed four times due to module 375.

It’s complicated by having to use both 1) recID from the Airtable output and 2) “role” from the JSON output.

Do I need to do something like start by initialising an array before the Iterator, then sequentially adding stuff to it?