Help

Re: Outputting specific fields in table

Solved
Jump to Solution
971 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Pedro_Pais
6 - Interface Innovator
6 - Interface Innovator

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?

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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 );

See Solution in Thread

1 Reply 1
kuovonne
18 - Pluto
18 - Pluto

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 );