I want to keep the list set to "Created Date - Oldest to Newest" and only show the 20 most recent posts

I want to display only the 20 most recent posts, while keeping the list set to “Created Date - Oldest to Newest”.

I am creating a chat application. If I set the “Maximum number of items” to 20 while keeping the list order as “Created Date - Oldest to Newest”, it will show 20 oldest items.

If more than 20 chats are sent, the 21st one will not be displayed in the list.

Is there any way to change this so that only the 20 most recent chats are displayed, while maintaining the “Created Date - Oldest to Newest” order?

Please let me know how to do this or what alternatives are available.

Hi @Mono,

You might try the following:

  • for each post, you have an ID. IDs should be incremented when post is created, and set automatically based on Posts → IDs → Maximum +1. As a result you’ll get the collection of posts with incrementing IDs.
  • then you create an auxiliary numeric property, call it “AUXLastPostID”, in Users collection. You set this property (probably the best place could be on-screen-enter action, when user enters the posts screen). You set it as following: Posts → IDs → Maximum-20.
  • when you display the list of posts, you set an additional filter that post ID is greater than “AUXLastPostID”. As a result, you’ll get the list filtered only by 20 latest posts. Why do you need this property: because you can’t set formula in the filter directly.
  • and then you sort the results by created date. By the way, you could also sort the results by ID, as the ID represents the creation sequence.

Please let me know if this works for you.

Best regards, Victor.

1 Like

Thank you!
We got it done that way.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.