Trying to add an additional filter layer in code to filter a repeater whose data is already being filtered using cms connected dropdowns (no code)

Question:
I’m trying to add an additional filter layer in code to filter a repeater whose data is already being filtered using cms connected dropdowns (no code). Basically, I have a collection of bands, a collection of venues and a collection of live shows with reference fields for band and venue. The no code functionality of the cms connected dropdowns filters the repeater results by band and venue but I only want to show results for live shows today or later - which the datepicker input doesn’t seem to support without code. So I achieved this in code by setting a filter to show results greater than or equal to todays date with the timestamp reset to zero, but that filter overwrites any other filter action happening and further disables my dropdowns. For example, the band dropdown will only allow the selection of the band in the first item of results filtered by todays date.

I’ve spent many hours with the AI assistant and have learned some things but we (me and the ai) cannot seem to get this to work.

I’m using wix studio editor. I’ve never posted before, so please guide me if I need to add anymore info. I’ve tried a query, I’ve tried different if statements to build the filter, I’ve tried disconnecting my dropdowns and going all code - I’m lost. Nothing I try (even getting the current filter and then building onto it with a .and) works to combine the dropdown filter for who (band) and where (venue) and the date (today or after). The current iteration of the function I am building is here:

function filterByDate() {
    let date = new Date();
    date.setHours(0,0,0,0);
    let filterDate = date.toISOString();
    let who = $w('#dropdownWho').value;
    let where = $w('#dropdownWhere').value;

    let filter = wixData.filter().ge("displayDate", filterDate);

    if (who) {
        filter = filter.contains("band", who);
    }
    if(where) {
        filter = filter.contains("venue", where);
    }
    if (who && where){
        filter = filter.contains("band", who.toString())
        .contains("venue", where.toString());
    }
    $w('#datasetLive').setFilter(filter);
} 

Your help is valued - thank you!

It’s not currently possible to have filters in both the UI and in code. It needs to be all one or the other.

As for the code issues one possible issue is that filterDate is being set to a string when it should be left as an object (ie. just the date object) so that the comparison can be done correctly per the docs: https://www.wix.com/velo/reference/wix-data/wixdatafilter/ge

Thank you! I was wondering if that might be the case that the two types of filters cannot be combined. At least now I have a solid direction to learn in. Just to be certain I am not missing something, is it not possible to filter by date field without using code?

About the date part, that actually works on its own as a filter so far it seems… I thought I read somewhere (or perhaps the ai assistant indicated) that a date has to be converted to ISOString to affect a filter? Is that not needed?

Thank you again for your assistance.

Correct. That’s currently not possible. Although there is a feature request to get this added that you can vote on if you’d like: CMS (Formerly Content Manager) Request: Filtering by a Particular Date Using Dataset Filters | Help Center | Wix.com

At least according to the documentation it seems the AI assistant is incorrect and it should be a Date object. I wouldn’t put too much stock into what AI assistants say. They often mix things up.