Using PHP and Curl (mainly because I don’t know any better…) I have a page that lists all the “Names” in one table and am attempting to do a nested list of “Orders#” under the “Name” however if I echo the “Orders” field it just outputs the word Array…
I’m assuming I need to make a GET call to the Linked Table I’m just not sure how to do that within the same foreach loop I’m using.
There’s two ways to do this, depending on how many records you’re really expecting.
Fetch related records one at a time
Build a filterByFormula parameter that uses OR() to get multiple records.
Option 1 would be extremely inefficient. And with option 2 you can request multiple records per call—either all the records associated with one related record, or (as I do in this example) all the records associated with an array of related records.
So, as you’re looping through the records from a table (we’ll call it “People”), you should build an array of the IDs you need to fetch from the related table (we’ll call it “Orders”). For the purposes of this example, I’m going to assume the each record from table People has only several related records in Orders (as opposed to hundreds).
The following code should provide a rough idea of how to do what you’re trying to do with only two requests to the Airtable API. One to fetch all the people, and one to fetch all the orders.
There are two functions below that I don’t define—they’ll need to reference whatever code you use to actually connect to airtable and retreive records.
I would like to ask if it’s possible to post a text value to the airtable record, which will turn on into a link to a table. When I try to post it via urlfetch it returns me an error (something like wrong value…). I saw that this text into link conversion works with Zapier, so I think it’s possible to make.
Any idea how to implement this functionality.
Yes. The text value you use is the Record ID of the record to which you’re “linking”. However, even if you have NOT checked “Allow Linking to Multiple Records”, you must still provide the Record ID in an array.