Help

Discover what data silos are costing your org in our commissioned Forrester study. Learn more

Invalid Filter Formula with user email

Solved
Jump to Solution
242 2
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi there, I"m new to Airtable and I keep seeing this “Invalid Filter By Formula” error.

I’m not sure what parts went wrong but this is my code:

Are there other methods to get a single user ?

THANK YOU for your help !

THE CODE

export const findUserByEmail = async (userEmail) => {
  const userRecord = await table
    .select({
      filterByFormula: `user_email=${userEmail}`,
    })
    .firstPage();

  if (userRecord.length !== 0) {
    return userRecord[0].fields;
  }
};

The ERROR

AirtableError {
  error: 'INVALID_FILTER_BY_FORMULA',
  message: 'The formula for filtering records is invalid: Invalid formula. Please check your formula text.',
  statusCode: 422
}

My temporary workaround solution is to use JavaScript filter method - probably not ideal but I haven’t figured out other solutions yet.
e.g.

const allUsers = await table.select().all();
const filterUser = allUsers.filter(
        (user) => user.fields.user_email === userEmail
      );
1 Solution

Accepted Solutions

Try wrapping ${userEmail} in quotes.

`user_email="${userEmail}"`

See Solution in Thread

2 Replies 2

Try wrapping ${userEmail} in quotes.

`user_email="${userEmail}"`

AHHH yes, that works! Thank you!