'Loading' a record

Is ‘loading’ a record the right concept.
Up to now I’ve been using lines like:

let record = await input.recordAsync("Who is Mum", view);

and in my head this has then let me wokr with a chosen record. But now I want to ‘load’ a record from a ‘link to another record field’ and I suspect I’m missing a fundamental point somewhere:

My code:

let table = base.getTable("Characters")
let deadMen = table.getView("Living Males")
var deadMansRecord = await input.recordAsync("Who Died", deadMen);

let theWiddow = deadMansRecord.getCellValue("Spouse")
let theWiddowID = theWiddow[0].id


let widdowHome = theWiddow.getCellValueAsString("Nation of Birth")

and the result when I run it for Albert.

Why is my getCellValueAsString(“Nation of Birth”) not returning Germany?


When retrieving the contents of a linked record field, you don’t have direct access to the linked records. What Airtable returns is an array of objects, with each object only containing the name and ID of the linked record, as your console log shows.

To get the record itself, you’ll need to directly retrieve it from the table where it lives using its ID. In this case, the target record is in the same table, so you won’t need to get a new table instance.

To retrieve a record using its ID, use the selectRecordAsync() method on a table. To extend your example above:

let theWiddow = deadMansRecord.getCellValue("Spouse")
let theWiddowID = theWiddow[0].id

let widowRecord = await table.selectRecordAsync(theWiddowId)

Now you can use the getCellValueAsString method on widowRecord.

let widdowHome = widowRecord.getCellValueAsString("Nation of Birth")

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.