Dear Bubblers, I’m stuck on something I’m sure is simple. How do I search for the most recent items of a datatype?
I have my RG set up and can find my datatype ok, but what ‘syntax’ would I use to display only the most 5 recent records, for example?
Many thanks.
You can use ‘created date’ or ‘modified date’ to sort them. Then just display the first 5 items.
Thank you Adam, but that is what I’m trying. I am constraining by Modified date, but then what, please?
I should add, that I don’t want to query the database for ALL my Contacts, as that will be in the thousands, so I just want to call for the most recently modified/created. I’m guessing there’s a formula for this that I’m missing…?
Ok, I see, so you don’t want to do ‘sort by creation date’ then return ‘items until#5’?
I’m not aware of anyway you can restrict the actual data being searched (unless it’s part of a specific list, or by using privacy rules).
If you’re searching for a type of ‘thing’ then the entire database will be searched to find entries of that type that match your constraints.
Using sort by created date, then ‘items until#’ will return the most recent items from your database. The sort is done on the server, and only the specified number of items are sent to the browser to load into the repeating group.
The only way I can think of to limit the actual data being searched for to the most recently added items would be to set up a backend workflow that maintains a specific list of the 5 most recent items, stored somewhere in a datatype on a list field. Anytime a new item is added it could add it to the list and remove the 5th most recent one.
That way you could just reference that list of the 5 most recent items and not even need to do a search.
Or you could use the same idea to modify a field on the datatype (such as a bolean field for ‘is recent’), and just keep it so that only the 5 most recent entries have that field set to yes. Then add that as a constraint on your search.
They both seem like slightly complex ways to go about returning a list of 5 items, but if you’re concerned about speed when searching the entire database, then they might be worth considering (or something similar), unless anyone else has any other suggestions. It might be worth testing a few options to see if there’s any significant difference in performance.
Otherwise, just doing a search, sorted by created date, items until#5 is the simple way to do it, and what I’d use.
1 Like
Ah that’s it - “items until#” that’s what I was after, many thanks, very helpful, including your other suggestions. I told you I was simple
I will go with the simple, now I know how to do it. All the best Adam.
1 Like