Help

Regex_match API and FilterbyFormula

762 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Prashanth_Kumar
5 - Automation Enthusiast
5 - Automation Enthusiast

I have an Airtable Database with Fieldname (“Expense”) and values. I am trying to write a JS code to query if user input available in this database. Here is what I got so far. Appreciate help in getting the RegexMatch / FilterbyFormula work. Thank you!

var Airtable = require('airtable');
var base = new Airtable({apiKey: 'myAPIkey'}).base('myAirtablebase');
var expenseCat = base('Imported table'); //name of the table

function matchDemo(airtableField, testString) {
console.log(airtableField,testString); // output works correctly "Expense Ikea"
const records = base('Imported table').select({filterByFormula:`REGEX_MATCH({${airtableField}},"${testString}")`}).all(); 
    return records;
    console.log(records);
};

matchDemo("Expense", "ikea"); // sample call to check if use input "ikea" is available in the Database

0 Replies 0