Get latest 10 entries form database

0
I have created an entity having city details. Now I want to retrieve only the latest 10 entries form the database and display it. But i am not able to retrieve that latest entered entries from database. I am using path constraint as ‘[city_name= ‘any city name ’ and ]’ but after “and” i am not able to understand what to write so that i can get only the latest 10 entries for that city from database.  If anyone could tell me how to retrieve the latest 10 entries of a particular city from the database and what can be the XPath constraint for it.
asked
3 answers
0

Depends on the functionality you want to go for but you have 2 two options:

If you do this in a datagrid: Just sort on createddate descending and show 10 rows, also disable the paging buttons. This will always show the latest 10 db entries.

 

If you do this in  microflow: also sort on createdddate descending but set the retrieve options to ‘custom’ and add the amout of 10. This will limit your retrieve to the 10 latest entries.

https://docs.mendix.com/refguide7/retrieve#1-introduction

answered
0

You need to somehow define ‘latest’. Usually, we do this by saving a timestamp in an attribute. If you have such an attribute, in the retrieve you use the Custom setting with offset 0 and amount 10. You sort by the attribute containing the timestamp, descending. This will give you the latest 10 results.

answered
0

store createdDate and use that to sort.

So much for build in features ;-)

answered