I have a dataset dsWork bound to collection Work. Work contains a reference field to a second collection, Composer. In effect, a straightforward ‘look up’ referential join between two tables.
I can then add and display items to a repeater bound to dsWork and display fields from either the primary collection (Work) or the referenced collection (Composer), all good, very useful capability.
I now want to be able to filter dsWork with a string contained in either an item from primary collection (Work) or an item from the referenced collection (Composer). I thus constructed an ‘or’ filter object as:
But alas, the filter on composerX.title does not work.
To assist my investigation, I applied a working filter to dsWork and inspected the subsequent item array. Here I can see that the referenced fields are loaded :
So my question is what syntax do I need for the filter object to be able to apply criteria one of the referenced fields, specifically ComposerX.lastName in the above item array.
Gareth, did you get anywhere with this ? It’s exactly what I am trying to do and I have explored almost every article on this subject in Wix forums, but still no definitive answer.
I spent ours on this too. I readed lot posts and tryed many coding without luck. Any solution someone please? Seems it not working jet, or i dont’t get it… I think i will do in the old way without related/referenced table → find something in table1 and then searching in table2 with table1._id string… or viceversa, get all table1.relatedfield_id’s in table 2 and then extra querry(s) for that id’s in table1
I concluded that, although you can read referenced fields, you cannot filter them. The only way to do it is using additional code.
You have to get the _id (the hidden unique ID) of the referenced table (in this case Composer), then filter your referenced field on that value.
In this example, you get the _id of the Composer.
Then filter Work collection on field composerX in Work contains the _id value from Composer.
Its messy but I got it to work.
Wix collections may appear to be a relational database, and it may well be under the bonnet, but we only see what Wix presents us with via their API.