I am chaining two .hasSome filters together. Each .hasSome filter works by itself, but when I combine the filters, it looks like neither filter is applied. I tried doing this two ways:
$w('#datasetServices').setFilter(
wixData.filter()
.hasSome('ClassCategory', $w('#dynamicDataset').getCurrentItem()._id )
.hasSome('_id', filteredTimeSlotIds )
)
And...
let filter1 = wixData.filter().hasSome('ClassCategory', $w('#dynamicDataset').getCurrentItem()._id );
let filter2 = wixData.filter().hasSome('_id', filteredTimeSlotIds );
let filter = filter1.and(filter2);
$w('#datasetServices').setFilter(filter)
Please help.
In your code, you use ClassCategory for the .hasSome(). Field keys start with a lowercase letter:
ClassCategory is the Field Name
classCategory is the Field Key
I am using the field keys. "_id" is the field key (not name). In your example above, _id is the the key for the ID field next to the Name field. BTW, I'm working on the Wix Bookings Services Collection and trying to join it to a custom table and I'm basically reaching the conclusion that these components are not stable enough to use with custom code.
The field definitions for the table are here: https://support.wix.com/en/article/corvid-wix-bookings-services-collection-fields According to that link, I should be able to apply filters to the Booking Services Collection for the serviceName field, but when I try to apply a filter, I only have two field options: slug and classCategory. To see what I'm talking about, Add a Bookings/Services dataset to a page and try to filter on the serviceName field. You can't because the field does not appear in the list, but the page above says that it should. I'm wondering if this is potentially having an impact on the filters I'm trying to apply above.
Honestly, very few of the things I've tried related to the Bookings table and filtering Booking information seem to work. It really makes me wonder if anyone is using anything other than the pre-built components. I simply wanted to create a custom filter on services based on a separate custom table and call the API to submit bookings. I thought this would be a couple days, but I've now spent two weeks trying to create a custom booking experience.
Tables referencing the Services collection constantly kept corrupting and lots of the data specs (for example, those on the page above) are not correct. Support seems to have fixed the data corruption issue... Well, at least I assume it's fixed. It's working again, even though I never heard back from them. I assume they fixed it or it somehow it just started working again. The specs indicate these things should work, but at the end of the day, they just don't.
I'm using the forum because contacting support does not seem to do much good. You submit tickets into a black hole and when you try to follow up on them you just hear that someone will contact you if you have any questions. I guess we're just expected to keep checking back every couple days to see if things are working or not, I'm not really sure. The other day, they appeared to be working on one of these problems at the same time I was working and they kept deleting my code and data from the tables. I now keep a backup copy of code and data outside of Wix because I don't trust the stability of the framework. The whole thing has become very frustrating.
Make sure you use field keys and not field names:
You want something like this:
let filter = wixData.filter(); filter = filter.hasSome('classCategory', $w('#dynamicDataset').getCurrentItem()._id ); filter = filter.hasSome('_id', filteredTimeSlotIds ); $w("#datasetServices").setFilter(filter);