Thanks for responding @tsuyoidesigns ! I tried that but it doesn’t allow me since it queries different collections (“Clients” collection for the referenced field and the actual collection “Companies”).
Here’s the code I came up with:
let filter1;
let filter2;
export function searchBtn_click(event) {
wixData.query("Companies")
.contains("companyName", $w('#searchBar').value)
.or(wixData.query("Clients")).contains("clientName", $w('#searchBar').value)
.find()
.then((results) => {
if (results.items.length > 0) {
let firstItem = results.items[0];
filter1 = firstItem.companyName;
filter2 = firstItem._id
// filter
$w("#dataset1").setFilter(wixData.filter()
.eq("companyName", filter1)
.or(wixData.filter()
.eq("clientName", filter2)))
}
});
}
Here’s the console result:
