Fastest way to retrieve a specific record by ID

Hey folks,

I’m working on a scripting action step for an Automation. It feels like querying the whole table just to search through the records is inefficient. I’m a frequent user of the Airtable API and am very used to simply asking for the record object by its ID.

Can I make this simpler?

I’m literally only trying to retrieve the field values of records that are linked to the record which triggered the automation. The Automation builder UI doesn’t allow for “looking up” fields from linked records.

// Get collaborator email from Client record.
let clients_table = base.getTable("Clients");
let queryResult = await clients_table.selectRecordsAsync(); // get all records in Clients table
let client_record = queryResult.getRecord(`${inputConfig.client_id}`) // find the one with the client_id from input
output.set("am", client_record.getCellValue("Account Manager").email)

// Get Site record linked to the Project record
let projects_table = base.getTable("Projects");
let projectQueryResult = await projects_table.selectRecordsAsync(); // get all records in the Projects table
let project_record = projectQueryResult.getRecord(`${inputConfig.project_id}`)
let linked_sites = project_record.getCellValue("Sites") // array of all linked sites

Not currently. I agree that getting a list of all records before you can ask for a specific record feels like a roundabout approach, but it’s the only approach available at the moment. Here’s hoping that we can eventually call getRecord directly on a table or view instance!

1 Like

Well, I’m at least glad I wasn’t missing something obvious. Thank you!

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