I assume you have a working API integration without the filtering feature implemented, right? If so, paste your working example here, and I’ll show you how to add the filterByFormula feature.
A formula used to filter records. The formula will be evaluated for each record, and if the result is not 0 , false , "" , NaN , [] , or #Error! the record will be included in the response.
If combined with the view parameter, only records in that view which satisfy the formula will be returned.
For example, to only include records where Name isn’t empty, pass in NOT({Name} = '') as a parameter like this:
A formula used to filter records. The formula will be evaluated for each record, and if the result is not 0 , false , "" , NaN , [] , or #Error! the record will be included in the response.
If combined with the view parameter, only records in that view which satisfy the formula will be returned.
For example, to only include records where Name isn’t empty, pass in NOT({Name} = '') as a parameter like this:
So… As you didn’t read my question properly, I’m here to answer it.
Using the airtable package, airtable.js, I’d reached what I wanted using the filterByFormula inside the select() function with a custom function that concatenates the fields I want to filter by using the AND() clause.
Here’s the solution:
function generateFilterWhereField(field, data){
var filter = "{" + field + "} = \"" + data + "\"";
return filter;
}
function generateAndFilter(fieldsAndValues){
var filter = "AND(";
for(let key in fieldsAndValues){
console.log(key);
filter += generateFilterWhereField(key, fieldsAndValues[key]);
filter += ',';
}
return filter.substring(0,filter.length-1) + ")";
}
It helps identify a single record inside your table, when you don’t have the Hash ID information to use .find().