Hi Anthony,
that is pretty close to what I need, but it gets even further.
It should not just group based on a value in one field, but in 2.
So if field value 1 and field value 2 (of one row) is equal to field value 1 and field value 2 (of other rows in my data collection) then choose the newest based on “created date”.
So my data collection looks like that:
The first 4 rows have the same owner. 3 of those with the same location.
The repeater for this owner should only show 2 containers. (see below)
The last one has another owner and should not be shown. (which works - Code below)
Live it looks like that:
So in this example the location for the first 3 is the same and also the Owner is the same. Only the Points are different. The newest is the one on top and I want the repeater only to show this one. (green) As the others are outdated.
The last one is also correct. I only have one in my database for this owner. (yellow)
If I would have more for the same owner & location I also just would want to show the newest .
The (red) is not given as it has another Owner. (which works fine)
Also the idea with flagging duplicates in an additional dupl field sounds interessting, but also here the code need to check for 2 fields (location & Owner), which makes it tricky to identify upfront.
Do you have a suggestion?
Thanks
If you are interested here is my Code to check for the correct User data:
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( ‘#PunkteKonto’ ). onReady (() => {
let user = wixUsers.currentUser ;
let userId = user.id ;
let itemUser = $w ( '#PrivateMember' ). getCurrentItem (). _id ;
if ( userId === itemUser ) {
$w ( "#listRepeater" ). onItemReady (( $item , itemData , index ) => {
$item ( "#Name" ). text = itemData.Name ; //(location)
$item ( "#Level" ). text = itemData.level ;
$item ( "#Punkte" ). text = itemData.punkte ;
$item ( "#image" ). src = itemData.Image ;
});
wixData . query ( ‘Konto’ )
. eq ( “copyOwner” , userId )
. find ()
. then (( results ) => {
if ( results.totalCount > 0 ) {
$w ( ‘#listRepeater’ ). data = results.items ;
}
else {
$w ( ‘#listRepeater’ ). hide ();
$w ( ‘#search’ ). hide ();
$w ( ‘#PunkteSeiten’ ). hide ();
}
})
. catch (( error ) => {
console . error ( error );
});
This works fine. I want to add the described condition to that code.