Getting records using a foreign key

Hello!

I have two tables linked by a foreign key. How can I get the second table entries that reference the first table entry?

The fact is that the record ID is stored in an array. I tried to use the ARRAYJOIN function, but it returns a string from the display names, not an ID

Thank you in advance!

You’ve posted this question to the API Category, but this doesn’t sound like you’re using the API because the API always returns the IDs (as opposed to the display names). If you are using the API, what programming language are you using?

Regardless, here’s two ways to get the Record IDs of related fields. Assuming we have a Products table and a Vendors table:

Using the Airtable app

  1. In the Vendors table, create a Formula field that simply displays its own RECORD_ID()
  2. In the Products table, create a Linked Record field that links to Vendors.
  3. In the products table, create a Lookup field that references the field created in step 1.

Using the Airtable api

  1. Make a request to fetch a record from the Products table
  2. Using the record IDs from the Vendors field, create a new request for the Vendor table with a filterByFormula that looks something like this OR(RECORD_ID() = 'recXXXXXXXXXXXXXX',RECORD_ID() = 'recXXXXXXXXXXXXXX') or this SEARCH(RECORD_ID(), "recXXXXXXXXXXXXXX,recXXXXXXXXXXXXXX")

Thank you very much!