Skip to main content
Solved

How to get field names by one request?


Hi, I am trying to get field names by request in table.

airtable.table('Classes').select({
  filterByFormula: `SEARCH(RECORD_ID(), "recr0DOF3YWjN9wAH,recwrHZ9zBIYFiU07,rectGHWsZVmkeRwGh,recJKCgej9ihrL2pK") != ""`,
}).firstPage().then((data) => {
    data.forEach((data) => {
       console.log(data);
    });
 });

In Students I get field ID’s, but I want to get it’s names by one request:

I tried to search with select by record names, but it didn’t work. Table structure:

Best answer by kuovonne

heldinshon wrote:

This is a question… How I should do it? I get only students ids and can’t get it’s names


You have to match up record IDs with names after you get the data from the [Students] table.

View original
Did this topic help you find an answer to your question?

6 replies

kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5995 replies
  • August 8, 2022

Welcome to the Airtable community!

It looks like you are using the REST API. Are you trying to get field names like {Students} or {Name}? Or are you trying to get field values like [Joe, Mike, Jenny]?

In the REST API, when returning the value of a linked record field, you get an array of record IDs, as shown in your screen capture. You cannot directly get the student names. You can go to your [Students] table and query that table for the records with the returned record IDs.

If you know the name of the class and want all the students, you could also try getting the data by querying the [Students] table for students in the given class.


  • Author
  • New Participant
  • 3 replies
  • August 8, 2022
kuovonne wrote:

Welcome to the Airtable community!

It looks like you are using the REST API. Are you trying to get field names like {Students} or {Name}? Or are you trying to get field values like [Joe, Mike, Jenny]?

In the REST API, when returning the value of a linked record field, you get an array of record IDs, as shown in your screen capture. You cannot directly get the student names. You can go to your [Students] table and query that table for the records with the returned record IDs.

If you know the name of the class and want all the students, you could also try getting the data by querying the [Students] table for students in the given class.


I don’t wanna query all table. I have class name and I want to get students names like [Joe, Mike, Jenny] by class name. Can I get it in 2 requests? First is students linked ids by {Name} and then second get {Students} names by {Students} ids from first request?

I am using this lib GitHub - Airtable/airtable.js: Airtable javascript client


kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5995 replies
  • August 8, 2022
heldinshon wrote:

I don’t wanna query all table. I have class name and I want to get students names like [Joe, Mike, Jenny] by class name. Can I get it in 2 requests? First is students linked ids by {Name} and then second get {Students} names by {Students} ids from first request?

I am using this lib GitHub - Airtable/airtable.js: Airtable javascript client


Yes, you can get all the info in two requests (assuming that you need only one request per table, and do not need to deal with the max page size of 100 records). You may need to do a bit of processing after you get the data to put it into the format you want to use.


  • Author
  • New Participant
  • 3 replies
  • August 8, 2022

This is a question… How I should do it? I get only students ids and can’t get it’s names


kuovonne
Forum|alt.badge.img+17
  • Brainy
  • 5995 replies
  • Answer
  • August 8, 2022
heldinshon wrote:

This is a question… How I should do it? I get only students ids and can’t get it’s names


You have to match up record IDs with names after you get the data from the [Students] table.


  • Author
  • New Participant
  • 3 replies
  • August 8, 2022

Oh… It’s an adjacent object! I thought these were different structures, but the names are the same) Thank you)


Reply