I am building a chat function on my app and next to the chat there’s an repeating group of users that the current user has “matched” with. The data type of that repeating group is Users. So it shows all users that the current user matched with (Do a search for: Users. Constraints are current user and current cells user). It also shows the last message between the two users. The last message is visible since I have a text in the repeating group that is: Search for Messages: last item’s MessageContent.
I want the repeating group to be sorted by Messages and not Users, if that makes sense? I know the data type is User, but I just want it to be sorted by last messages. I have a field for date/time in messages, so I should be able to do this, right?
There is no straight-forward way of doing this as far as I know. But here is a workaround. You will start with messages in your User repeating group, filter the messages so you only get one from each user, get each message’s creator.
See a small demo below. This demo, just treats there is a public message area of course, but the idea is same. The repeating group on the left, displays the users sorted by the last message sent.
The repeating group on the right is nothing special, just messages sorted by creation date.
The one on the left starts with messages:
Then, filters them to get the last message by each user (even if it asks first item is this message because it is sorted by creation date in descending order)
The inner Search for messages is searching the messages by this message’s creator:
Finally, you get each item’s creator to get the actual user (this should return a unique list because we only get one message from each user in the filter):