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