Can't access specific linked record cell value

Topic Labels: Scripting extentions
775 1
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

We are trying to access a specific cell value in the code. We are able to query the records and getCellValueAsString. However when we try to call a specific record from a field we get a completely different record from that field and there seems to be no pattern to it.

let table = base.getTable("🌻 Groups");

let queryResult = await table.selectRecordsAsync();

let record = queryResult.records[1];

console.log(record.getCellValueAsString("This Record 🆔"));

console.log(record);`Preformatted text`

As you can see we are trying to get the first record in the list, but we actual get the 27th and if we increment the value to the second, we may end up getting the 35th record. However all of the fields within the row that is selected is present.

The reason we want to do it is because we want to update a linked record to a cell while leaving the previously linked records intact.

1 Reply 1

array[1] does not give you the first item in an array, it gives you the second item. Javascript arrays start counting at 0. If you truly want the first item in an array like queryResult.records, you need queryResult.records[0].

Are you trying to get “a record from a cell”, “a cell from a record”, or “a record from a linked-records cell of another record”?

When pulling records from a table, the easiest way to guarantee the order of records in a predictable manner is to query records from a specific view within the table, not the table. At table-level, record order may-or-may-not-be arbitrary. At view-level, record order is constant.