Forum Academy Marketplace Showcase Pricing Features

Sort by in a repeating group problem

Hi, I’m trying to sort a list of messages with the users who have subscribed at the top, so “subscription_status = active”, and then all the other users who don’t have a subscription. And within each user type, it sorts according to the last message received. Here’s what I mean:

One thing you can try is doing your first search (and sorting it as you want) then MERGEing that with another search (again, sorting it as you want).

Thanks a lot, but how do I sort? I am a little lost if you could show me with a screenshot thank you very much…

Here are the data types

User : subscription active (yes/no)

Chat : Creation Date

Add a Date field to your Data Type “Chat” called “LastMessageSentOn” for example. Then whenever a new message is sent, update that field either with the current date/time or with the creation date of the message. In your search you’ll sort by that field and either use Yes/No.

Thanks, but the problem is that after sending a new message, the chats of users without a subscription will be above those with a subscription.

In fact, I try to prioritize one sort over another.

I’ve no idea what your DB looks like. But as @firstfifteensoftware suggested. You can do a search for users where SubscriptionActive = Yes, sort by LastMessageSentOn merged with do a search for users where SubscriptionActive = No, sort by LastMessageSontON

Or have it in 1 search that you hide in a hidden popup for example, and then you reference that search using the :filtered expression

the data source of my RG is search for a chat :confused:

this is what i tried to do (for the filter for subscription (yes/no) it works but when I want to put it with the modified date filter the user who doesn’t have a subscription and who sends a message last goes above the user who has a subscription (and that I don’t want) ^^)

Actually, we might be overthinking this. I’ve honestly no idea if the following will work, so bear with me.

  1. Add a popup on your page that no one will ever see and place a repeating group in it. That repeating group will just have the Data Type Chat and the data source will be do a search for chat (with the necessary constraints you want to add). Let’s call it “rg-chat”

  2. on your actual RG that your users will see, set the following data source: rg-chat’list of chats: filtered. This filter will be advanced and your expression will be this chat’s participants minus item current user first item’s subscription status is active. Then add :sorted and sort on “LastMessageSentOn”. You’ll have to create this field on your chat data type.

  3. After the above expression, add merged with

  4. The you reference rg-chat again, after merging, with the same advanced filter as in step 2. But now instead of “…is active” use “…is not active” and add that sorting again.

Let’s see if this works.

Add a field to your USER table called “last_chat_date”.

I am not 100% certain, but I think @oliviercoolen meant to add this field to the User table, rather than the Chat table.

This approach unfortunately won’t work. A user can have multiple chats, so whenever a new message is sent in another Chat, you’ll update a user’s data field that is not longer relevant for the previous chat

1 Like

I created the field in chat data type but it doesnt appear

It should be a Date, not a Message :wink:

oh my bad

But then couldn’t I just put “modified date”? Because with each new message the chat is modified (I did this in the workflow for each new message).

That depends on how you want sort your chats. If you want to sort them by modified date, sure. But then whenever a mission is added or a participant joins/leaves a conversation, it will be on top too

Also, no need to use a conditional here. Reread my 4 steps again, I believe you missed something