multiple hasSome filters not working together

Hi,
I’m creating a filter search for my users to search a database using dropdowns and checkboxes. It’s working perfectly fine except the hasSome() components. So my filter code looks like this:
$w(“#buyDressesDataset”).setFilter(wixData.filter()
.eq(“approved”, true )
.eq(“selling”, true )
.contains(“colour”, $w(‘#colourDropdown’).value)
.contains(“brand”, $w(‘#brandDropdown’).value)
.contains(“occasion”, $w(‘#occasionDropdown’).value)
.hasSome(“size”, [checkboxXS, checkboxS, checkboxM, checkboxL])
.hasSome(“region” [checkboxEast, checkboxNth, checkboxSth, checkboxWest])
)

The really weird thing is the code works perfectly if I take out just one of the hasSome() filters . So if I comment out either of the hasSome() lines, the search works perfectly where it takes all the information from the dropboxes and the checkboxes and shows results that match the search. But if I try and use the hasSome() twice, all filters fail and I am returned with no results at all.

Any ideas why this is happening and/or how I can get around it?

Thanks :slight_smile:

You’re missing a comma in your last .hasSome()
.hasSome(“region”, [checkboxEast, checkboxNth, checkboxSth, checkboxWest])
I added a comma after “region”.

I hope that helps.

1 Like

@yisrael-wix thanks for replying! I fixed the typo but it hasn’t fixed the problem :frowning: Any other ideas?

Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

Also, keep in mind that the values in the arrays for the hasSome() must be string or number. (They can also be date but I guess that’s not relevant in your case.)

@yisrael-wix
https://editor.wix.com/html/editor/web/renderer/edit/05611730-fe22-4f71-824d-c8279175cb27?metaSiteId=e6adfd3c-568b-49b9-84d6-ca48aee7e9e0&editorSessionId=968785f5-7479-4bd4-805f-1fcfdd3986e2&referralInfo=dashboard
The page I’m working on is called “memberAddedDresses Buy Dresses”

I’m using string values I think - and the thing is they both work perfectly fine independently of each other but don’t work together?

Let me know how you go, appreciate the help :slight_smile:

@yisrael-wix have you had any luck with this? I still can’t work it out :frowning:

Oh my mistake I didn’t realise you had fixed it! Thank you so so much, you’re a legend!!

You are ending up with null entries in your query. For example, you should build your region array like this:

// Determine value of region checkboxes
 let regionArray = []
 if ($w("#eastCheckbox").checked === true)
        regionArray.push("Eastern");
 if ($w("#icCheckbox").checked === true)
        regionArray.push("Inner-City");
 if ($w("#nthCheckbox").checked === true)
        regionArray.push("Northern");
 if ($w("#sthCheckbox").checked === true)
        regionArray.push("South-East");
 if ($w("#westCheckbox").checked === true)
        regionArray.push("Western");
    console.log('regions', regionArray);

And then, in the query, you would use this:

.hasSome("region", regionArray)

The array for the sizes should be built in the same way.

1 Like

Hello!I ask for your help - how do I link filters together? I have several drop-down lists and they work as a separate filter. And it doesn’t allow you to select 2 parameters. What should I do? For example, I need to set up a filter by area: from … to … m2 I don’t understand how to link this data

In my project hasAll will work in a query. But hasSome is not working together for different selection list. How to solve it?
I want to replace hasAll with hasSome. Thank you in Advance.

function loadDataToRepeater(selectedTags1,selectedTags2,selectedTags3,selectedTags4,selectedTags5,selectedTags6) {

    wixData.query(collectionName)
 .hasAll(fieldToFilterByInCollection,selectedTags1)
 .hasAll(fieldToFilterByInCollection,selectedTags2)
 .hasAll(fieldToFilterByInCollection,selectedTags3)
 .hasAll(fieldToFilterByInCollection,selectedTags4)
 .hasAll(fieldToFilterByInCollection,selectedTags5)
 .hasAll(fieldToFilterByInCollection,selectedTags6)

 .find()
 
 .then(results => {
                          $w("#repeater1").data = results.items;
 })
 }