Help

How Do I pass 'options.fields' to the selectRecordsAsync() method?

Topic Labels: Scripting
Solved
Jump to Solution
892 3
cancel
Showing results for 
Search instead for 
Did you mean: 
BarryBrewer
5 - Automation Enthusiast
5 - Automation Enthusiast

I received the following prompt from Airtable's IDE, but I don't understand what it is asking me to do?

Could someone please give an example as to how I would pass options.fields to selectRecordsAsync()? TIA!

"Calling selectRecordsAsync() method without passing options.fields is discouraged.  Passing options.fields allows you to request just the fields you need."

1 Solution

Accepted Solutions
Sho
11 - Venus
11 - Venus

Pass the field names as an array shown below

let query = await table.selectRecordsAsync({fields: ["Field name1","Field name2"]});

 

See Solution in Thread

3 Replies 3
Sho
11 - Venus
11 - Venus

Pass the field names as an array shown below

let query = await table.selectRecordsAsync({fields: ["Field name1","Field name2"]});

 

BarryBrewer
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you, Sho!

I am a little unclear about a few things here, if you don't mind.

 

let query = await table.selectRecordsAsync({fields: ["Field name1","Field name2"]});

 

Do I use the word you typed in, "fields", then inside the brackets type the names of the fields(columns) from my base, which is what I did. 

 

({fields: ["Field name1","Field name2"]})

 

AirTable seems to only return the record IDs and the first column, not returning the field names I typed in.

 

records: Array(11)
0: Object
id: "recy5EPgK58mBL8Xz"
name: "Miako"

 

BarryBrewer
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Sho, I just saw a little more detail in the Airtable docs that really helped me to understand what is going on, so thank you for getting me started here.