selectRecordAsync only returns record ID and Name

I am attempting to create a simple script which will count the number of entries in a linked lookup field. My plan was to invoke .selectRecordAsync() on the table of interest to pull the records and count the number of entries for a given record in that field.

I’ve run into an issue early on with this script: the selectRecordAsync call appears to only be returning the name field and Id for the records, but no other data. My code is below.

let vendorTable=base.getTable("Vendors");
let quoteField=base.getTable("Vendors").getField("Quoted Parts")
let records= await vendorTable.selectRecordsAsync()

let exampleValue=records[0].getCellValue(quoteField)

I’m getting the following responses in the console.

My table is structured as follows:

The only issue I can think of off hand is that all of the fields (aside from name) are linked or lookup values.

What am I missing here?

What is returned by calling selectRecordsAsync on a table instance is an instance of another class known as a RecordQueryResult. It’s not a direct array of records that can be accessed as you’re trying to do in this line:

let exampleValue=records[0].getCellValue(quoteField)

A RecordQueryResult instance contains three properties:

  • recordIds - a string array of all record IDs from the table
  • records - an array of Record instances representing all records in the table
  • getRecord - a method that can be used to retrieve a single record by its ID

On a side note, you don’t need to use the getField method on a table to retrieve a field to use as part of a getCellValue call. You can just pass the string name of the field.

Using that info to access the first record from the records array on that query, your code whould look like this:

let vendorTable = base.getTable("Vendors");
let query = await vendorTable.selectRecordsAsync()

let exampleValue = query.records[0].getCellValue("Quoted Parts")

Thanks @Justin_Barrett . This was exactly the issue. Much appreciated

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