Help

Re: Invalid Filter Formula with user email

Solved
Jump to Solution
1315 1
cancel
Showing results for 
Search instead for 
Did you mean: 
I_Love_Coding
4 - Data Explorer
4 - Data Explorer

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
Kamille_Parks
16 - Uranus
16 - Uranus

Try wrapping ${userEmail} in quotes.

`user_email="${userEmail}"`

See Solution in Thread

2 Replies 2
Kamille_Parks
16 - Uranus
16 - Uranus

Try wrapping ${userEmail} in quotes.

`user_email="${userEmail}"`

AHHH yes, that works! Thank you!