Skip to main content
Solved

Outputting specific fields in table

  • August 23, 2022
  • 1 reply
  • 24 views

Forum|alt.badge.img+9

I’m trying to test a very simple script, but I can’t seem to output specific fields to a table, no matter which fields I specific in selectRecordsAsync, the output is always the same: fields id and name.
My code:

let table = base.getTable("Procedimentos");
let query = await table.selectRecordsAsync({fields: ["Procedimento","Descrição"]});
output.table(query.records);

What am I missing?

Best answer by kuovonne

To get the cell values, you need to use getCellValue().

let table = base.getTable("Procedimentos");
let query = await table.selectRecordsAsync({fields: ["Procedimento","Descrição"]});

const data = query.records.map(record => ({
  "Procedimento": record.getCellValue("Procedimento"),
  "Descrição": record.getCellValue("Descrição"),
}))

output.table(data );

1 reply

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • Answer
  • August 23, 2022

To get the cell values, you need to use getCellValue().

let table = base.getTable("Procedimentos");
let query = await table.selectRecordsAsync({fields: ["Procedimento","Descrição"]});

const data = query.records.map(record => ({
  "Procedimento": record.getCellValue("Procedimento"),
  "Descrição": record.getCellValue("Descrição"),
}))

output.table(data );