Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Outputting specific fields in table

Topic Labels: Scripting extentions
Solved
Jump to Solution
208 1
cancel
Showing results for 
Search instead for 
Did you mean: 

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

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

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