Help

Finding records in a table based on field value

Solved
Jump to Solution
2198 1
cancel
Showing results for 
Search instead for 
Did you mean: 
DPG
6 - Interface Innovator
6 - Interface Innovator

I would like to find records whose ID field match a given value, playlistId, in a specific table I defined as playlistsRecords. In other words, I want to find matches in a field, get their record IDs, and if there are no matches to tell me that there are no matches. I've tried "playlistsRecords.includes(playlistId)" without success and suspect I need to rely something like the following:

 

base('Playlists').find(playlistId, function(err, record) {
    if (err) { console.error(err); return; }
    console.log('Retrieved', record.id);
});

 

Any pointers? Past experience?

 

1 Solution

Accepted Solutions
DPG
6 - Interface Innovator
6 - Interface Innovator

I beieve I figure it out myself, but more elegant solutions are welcome. 

Find my solution below:

 

var numberOfMatches = 0
for (var r = 0; r < Records.length; r++)
    {if(playlistId == playlistsRecords[r].getCellValue(idField)) { //If a given record's ID field matches the playlist ID
        numberOfMatches => numberOfMatches + 1}
    }
if(numberOfMatches < 1) {
  console.log('No matches, created new curator record in Airtable')
  }

 

This solution relies on a variable, numberOfMatches, that updates for every record match.

See Solution in Thread

1 Reply 1
DPG
6 - Interface Innovator
6 - Interface Innovator

I beieve I figure it out myself, but more elegant solutions are welcome. 

Find my solution below:

 

var numberOfMatches = 0
for (var r = 0; r < Records.length; r++)
    {if(playlistId == playlistsRecords[r].getCellValue(idField)) { //If a given record's ID field matches the playlist ID
        numberOfMatches => numberOfMatches + 1}
    }
if(numberOfMatches < 1) {
  console.log('No matches, created new curator record in Airtable')
  }

 

This solution relies on a variable, numberOfMatches, that updates for every record match.