Skip to main content

Hi all~

 

 

 

 

Recently, had to do this--and was confused because some of the documentation on "Expressions" was outdated. 

 

 

 

 

 

So i'll sort of lead you through a step by step of how to get the most RECENT record in a List View! 

 

 

 

 

 

 

 

 

Step 1: Getting the most recent date

 

 

 

 

 

To be able to use expressions, we need to have a data label. (** for better asthetics, you can always choose to hide this by unchecking 'Visible'**)

 

 

 

 

 

16249i559723C3218B19AA.png

 

 

 

 

 

Next, we configure the expression, to give us the most recent date!

 

 

 

 

 

 

 

 

Looking at the official documentation, I thought that there was a "Maximum" function under Date/Time :

 

 

https://help.k2.com/onlinehelp/k2smartforms/userguide/4.7/default.htm#SF-ViewDesignerLayout-CalcExpression.html?Highlight=maximum

 

 

 

 

 

 

 

 

However, this is not there anymore. Instead, we can use the "List Maximum" function under List Aggregators.

 

 

 

 

 

 

 

 

12771iBE9A7F19118C1702.png

 

 

 

 

 

 

 

 

Input the date column from your smartobject... and voila! You're good to go!!

 

 

 

 

 

 

 

 

To test this, feel free to run the view, and verify that the date returned in the datafield is the most recent date. 

 

 

 

 

 

 

 

 

Step 2: Passing the expression into the Smartobject

 

 

 

 

 

 

 

 

Now, you can do this any way you like. The way i thought was educational and interesting, is directly passing the expression into the smartobject, to filter out the result i wanted. 

 

 

 

 

 

Using the "Get List Items" method of my List View's smartobject........ 

 

 

 

 

 

 

 

 

16680i5CA8920AFA7300BE.png

 

 

 

 

 

 

 

 

I passed in the "Max Date" expression (the expression created on step #1). 

 

 

 

 

 

 

 

 

13269iABC30D9B7532C510.png

 

 

 

 

 

 

 

 

To get me the most recent "Title". 

 

 

 

 

 

 

 

 

15106i470F67EB2656C3A6.png

 

 

 

 

 

 

 

 

YAY! Done!

 

 

 

 

 

Now, we just add a few columns, with the titles and the dates.... and we can see that the most recent title is pulled back :) 

 

 

 

 

 

 

 

 

 

 

 

NOTE: data labels and button clicks are used for simplicity to easily show beginners how this functionality works. They are not the best / recommended way to do this. One can always use a stored proc or other advanced techniques to achieve the same thing. 

 

Thank you for the info! 


May I know the right date format . I'm not getting the right result :(


Reply