Using Code to Filter Dataset Not Working

Hey everyone, thanks for looking in

I have a dataset which contains Worker’s details.
This dataset needs to be filtered by the person booking based on location and product so I can find the right contact details for the worker responsible for that.


import { currentMember } from 'wix-members';
import wixData from 'wix-data';

$w.onReady(function(){
    $w('#repContactsDataset').onReady(function(){
        $w('#repContactsDataset').setFilter(wixData.filter())
PreLoadMemberData()
})
})

//Lets get the member and load the info
function PreLoadMemberData (){
currentMember.getMember()
    .then((member) => {
        const memberEmail = member.loginEmail
        const memberName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
        const memberPhone = member.contactDetails.phones[0]
        const memberLocation = member.contactDetails.customFields["custom.preferred-location"].value
        
$w('#inputName').value = memberName
$w('#inputEmail').value = memberEmail
$w('#inputPhone').value = memberPhone
$w('#dropdownLocation').value = memberLocation

    //check console

console.log ($w('#dropdownLocation').value)
console.log ($w('#dynamicDataset').getCurrentItem().title)
console.log ($w('#repContactsDataset').getCurrentItem())
    
    //now filter and find the one i need. Note that the location is confusingly saved under "title" in my dataset
        $w('#repContactsDataset').setFilter(wixData.filter()
        .eq("title", $w('#dropdownLocation').value)  
        .eq("product", $w('#title').text)
    )

console.log ($w('#dropdownLocation').value)
console.log ($w('#dynamicDataset').getCurrentItem().title)
console.log ($w('#repContactsDataset').getCurrentItem())

    })
  .catch((error) => {
    console.error(error);
  });

}

When i do this the console shows that the wrong product is the current item and i get the wrong product rep details.
Any idea why this is happening? Have been trying to figure this out for hours

I’m not sure if this is the only issue, but one problem I am seeing right away is that you are stringing .eq() together when I think you mean to use .and()

like
query eq XX title AND xzy product…

Take a look at the query docs for and and see if that helps https://www.wix.com/velo/reference/wix-data/wixdatafilter/and

Managed to do a work-around using the query function rather than filter! thanks for the reply!