Hi All, I could use a little insight into what's wrong with my formula.
It's scripted in my API, using Airtable.js with Next.js.
The following works with only the second two fields, which are multi-select, but ignores (or seems to ignore) the text input field "Title."
const records = await table
.select({
filterByFormula: `OR(
FIND(LOWER("${req.query.title}"), Title) > 0,
FIND("${req.query.module}", module) > 0,
FIND("${req.query.lessonprogram}", program) > 0
)`,
sort: [{ field: "RecordId", direction: "asc" }],
})
.all();
If I try to use AND, I get nothing:
const records = await table
.select({
filterByFormula: `AND(
FIND(LOWER("${req.query.title}"), Title) > 0,
FIND("${req.query.module}", module) > 0,
FIND("${req.query.lessonprogram}", program) > 0
)`,
sort: [{ field: "RecordId", direction: "asc" }],
})
.all();
However, through the REST API I get the JSON results I want, using AND (even if Title is an empty string):
https://api.airtable.com/v0/<appID>/<table>?filterByFormula=AND(FIND("", Title),FIND("Program+string", program),FIND("Module+string", module))&sort%5B0%5D%5Bfield%5D=RecordId&sort%5B0%5D%5Bdirection%5D=asc&api_key=<api_key>
Is there some way I can write the formula using scripting in the Next.js API that will return results on all three fields?
Thanks a million for any help!