Assign last Item in a column to variable

I am wanting to select the last item in a column and assign it to a variable. I have a repeater (dataset) of Dates and Names and want to grab the date in the last row.

KeyID | Date | Name

  1. |. 01-15-2012 | Homer
    2 | 03-08-2013 | Bart
    3 | 10-31-2014. | Marge
    4 | 07-20-2015 | Lisa
    5 | 08-12-2016 | Maggie


You can do this using the (undocumented) “listener” method on a repeater. Basically, you put an widget (I always use a hotspot) in the repeater row that will be your listener. From the outside, you move the repeater by (0,0), which will cause the hotspot to receive the On Moved event.

The cool thing is that this On Moved event will fire for every row instance of the repeater, and code in the On Moved event will have access to things like Item.index, etc. So here is the basic strategy:

  • From the outside, move the hotspot by 0,0, causing its On Moved event to fire for each row
  • In the hotspot’s On Moved event, check if the current row is the last row
  • If it is, grab the value of the date column in that row


On Click (or whatever event outside of the repeater)
  Move hotspot inside of the repeater by 0,0

On Moved  (of hotspot inside of repeater row)
  If (value) [[Item.isLast]] equals true
    set global variable to value [[]]

Never would have thought to use an onMove event to trigger, but it works! Thank you!!

1 Like

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