Jun 29, 2022 11:47 AM
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
);
Solved! Go to Solution.
Jun 29, 2022 11:54 AM
Jun 29, 2022 11:54 AM
Try wrapping ${userEmail}
in quotes.
`user_email="${userEmail}"`
Jun 29, 2022 01:08 PM
AHHH yes, that works! Thank you!