Filter Products by collection using code

export function collectionDropdown_change(event) {
let filter = $w("#collectionDropdown").value;
$w("#dynamicDataset").setFilter(wixData.filter().hasSome("collections", filter))
}

I’m using a dataset to display products in repeater and I added a dropdown button to filter collections. I added the above code which I found in corvid, but it still not working.
Note that I know this question is repeated but I’ve been looking for an answer over internet since 2 days and I couldn’t find a complete one.
Thank you in advance.

Code looks good, provided you have referenced the field name correctly.

Could be an issue related to permissions in the dataset element. Is it set to Write Only? Does the console throw up any errors when you run the code?

I am running into the same issue … I believe it has something to do with the “collections” field in the “Products” database being a referential field …