Skip to main content
Solved

Script Querying specific records with a specific value with more than 100 records

  • September 15, 2022
  • 1 reply
  • 11 views

Is it possible to select records in scripting with specific conditions? If I wanted to get all the records that have a field value of green, how would I write that query? I don’t want to just get all the records; I want specific records with more than 100 results.

Best answer by kuovonne

You currently cannot specify conditions when querying records in scripting. You must get all the records and then filter the result in JavaScript.

const table = base.getTable("myTableName")
const fieldName = "color"
const queryResult = await table.selectRecordsAsync({fields: [fieldName]})
const greenRecords = queryResult.records.filter(record => (
  record.getCellValueAsString(fieldName) == "green"
))
console.log(greenRecords)
View original
Did this topic help you find an answer to your question?

1 reply

kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5995 replies
  • Answer
  • September 15, 2022

You currently cannot specify conditions when querying records in scripting. You must get all the records and then filter the result in JavaScript.

const table = base.getTable("myTableName")
const fieldName = "color"
const queryResult = await table.selectRecordsAsync({fields: [fieldName]})
const greenRecords = queryResult.records.filter(record => (
  record.getCellValueAsString(fieldName) == "green"
))
console.log(greenRecords)

Reply