Help

Re: Retrieve all fields from a specific record

4607 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Angela_Janielle
4 - Data Explorer
4 - Data Explorer

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!

4 Replies 4

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.

Thank you! I’ll give that a whirl

super long and anoying btw
when we will see a beautiful
record: {
field:value,
field:value,
field:value,
}

I don’t know, as I do not work for Airtable. If I had to guess, my guess is that Airtable will not implement this.

If you want to see records in that format, you can use helper functions create that format. I actually used such a helper function to create that format around when scripting came out, but I have since abandoned doing so on a regular basis a I no longer find it useful.