Retrieve all fields from a specific record

Hello All,

I’m attempting to wire up a script to a button field. When the button is clicked this is what happens:

  1. all the fields associated with the clicked button’s recordID are gathered in an object:
let data = {
  "field": "value",
  "field": "value",
  "etc...": "etc..."
}

this data object is then sent to a webhook via fetch post request

What I have is this:

let pipeURL = "webhook URL here";

let table = base.getTable("GPP Website Leads");

let view = table.getView("Grid view");

let queryResult = await view.selectRecordsAsync();

console.log(queryResult.records)

This works, but only returns the recordID and the first field in the view. I’m sure it’s trivial but I can’t figure out how to loop through and get all the fields & associated values for a given recordID. The I could populate my data object with the fields and the values.

Thanks for the help!

Welcome to the Airtable community!

You can get a list of all the fields from the table object. Once you have all of the fields, you need to use getCellValue to get the actual field values for the record.

1 Like

Thank you! I’ll give that a whirl