Help

Re: Getting records using a foreign key

1326 0
cancel
Showing results for 
Search instead for 
Did you mean: 
11114
4 - Data Explorer
4 - Data Explorer

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!

2 Replies 2

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")
11114
4 - Data Explorer
4 - Data Explorer

Thank you very much!