Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Outputting specific fields in table

Topic Labels: Scripting extentions
Solved
Jump to Solution
1871 1
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 );