How To Filter Records Where A Linked Record Field Contains A Specific Linked Record?

Hello all,

I’m working with a dataset where a user has permission to access multiple accounts, and an account can be accessed by multiple users (there is a many-to-many relationship between users and accounts). I’m importing this dataset into Airtable as a CSV file via a script that does two things:

  1. If an account in the dataset does not already have a record in the Accounts table in Airtable, it creates one

  2. If an account in the dataset already has a record in the Accounts table in Airtable, but the User field (a linked record field that allows linking to multiple records) does not contain a link to a linked record for a specific user (set in a variable elsewhere in the script), then it adds that user to the User field

The issue that I’m running into is that after doing a lot of searching I’m not sure how to correctly write the following actions into my script:

  1. Filter records on the Accounts table where the User field (a linked record field that allows linking to multiple records) contains a specific linked record

  2. Add the linked record for the specific user to the User field on the Accounts table without overwriting the linked records for other users that are already linked in this field

If someone can point me in the right direction here, it would really help me out a lot.

Thanks in advance!

Welcome to the Airtable community!

When appending a value to a linked record field, your array needs to include all the previous values in addition to the new value that you want to add.