Airtable adding New Linked Record through Airtable Update Record Module

Hey guys, I have a problem with creating new Linked Records in Airtable that I had to solve in a strange way, but I am hoping to gain your insight on how I can solve this in a better way.

If you have a situation, where you want to add new Linked Records to an Airtable record, in my case this is a Contact, and I want to attach an Event that they are attending.

The expected value of a Linked Record field is a Record ID.

However, if you want to add a New linked record to the ones you already have.

Example:

Contact 1 has already attended Event 1, Event 2

Now I want to append a new event to Contact 1, so that they have Event 1, Event 2, and Event 3.

The update record module is set up in a strange way such that if I disable the map function, and I manually click on “add item” and write the Record ID for Event 3, the new values I am getting are:

Contact 1 has attended only Event 3. Event 3 overrides the previous values of Event 1 and Event 2, as associated records.

I have read the Airtable documentation and it states that it requires an Array. So if you want to add Event 3, you want to return the Record IDs of Event 1, Event 2 and Event 3. Example:

[“recS1lO1doK0w4jQn”, “recxTIIBYuq6RfcKI”, “recM5WTgqWgUuaiyG”]

However, if you are trying to add records when the “map” function is disabled, you have to manually add as many “items”, as there are Record IDs, which cannot be done programmatically. Hence, this doesn’t really work.

If I activate the “map function”, it doesn’t expect an Array such as [“recS1lO1doK0w4jQn”, “recxTIIBYuq6RfcKI”, “recM5WTgqWgUuaiyG”]. Which I interpret as if I cannot be adding more than one record at a time, which also overrides the previous ones.

Hence, I had to create an HTTP module and make an API request to Airtable

This is just to append the new event to the old ones. Is there a more clever way to do this instead of doing two different queries?

Thank you for your help!

I’m not 100% sure how you have this Event IDs column set up in Airtable but in general you can use the map() function to get a primitive array of the existing Event IDs and then add in a new ID using the add() function. You would then just pass that new array of string primitives to the Update a Record module.

2 Likes

Hey Khurram, thank you very much for your reply. I had to lookup how map() and add() functions work, but that actually solves the problem, yes.

Here is an example I tried:

Here is the Event IDs that are associated to a Contact before the automation
image

Here is how I used the map() function

Here is the output:

All good!

Now I can use the Update Record module instead of making a second one through an HTTP request. Thank you!

4 Likes