sort calendar items ascending but only need top 5 from todays date - InfoPath Dev
in

InfoPath Dev

sort calendar items ascending but only need top 5 from todays date

Last post 08-15-2013 05:43 AM by ErnestoM. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-14-2013 02:13 PM

    sort calendar items ascending but only need top 5 from todays date

    Hello,

     I am displaying calendar items in a form and I need the most current 5 calendar events starting from now().

       Very easy if I needed desc as I would sort DESC and then put in an expression: position()>5

       with ascending the position() function will not work since the sort order is going to count from the beginning and stop after 5, thus leaving nothing to show since there are 100's of calendar entries.

    Any clever methods to do this?

    I am using qRules to do the sorts

    SharePoint 2010, InfoPath 2010, qRules

  • 08-14-2013 02:23 PM In reply to

    Re: sort calendar items ascending but only need top 5 from todays date

    Hi-

    You could:

    1. Query the calendar items

    2. Sort them DESC (in the 2DS)

    3. Use a method like the one described here to copy the individual rows over to another location (main DOM perhaps) on the form's schema: http://www.infopathdev.com/files/folders/qrules/entry58854.aspx. You would iterate 5 times only but the steps should be quite similar.

    4. Sort them ASC (in the main DOM) and display them on the view.

    Hope this helps!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 08-14-2013 03:05 PM In reply to

    Re: sort calendar items ascending but only need top 5 from todays date

    Hi Ernesto,

     Thinking this through, could this scenario happen?

    Today = 8/14/2013

    get calendar items desc

    item#    |   Start Date

    item 1      Oct 1

    item 2      Sept 15

    itme 3      Aug 19

    item 4      Aug 18

    item 5      Aug 17

    item 6      Aug 16

    item 7      Aug 15

    item 8      Aug 14

    >>copy table , 1st 5 items

    That would copy over Aug 17th to Oct 1st items

    reverse the sort

    Aug 17th

    Aug 18th

    Aug 19th

    Sept 15th

    Oct 1st

    If I'm following your idea correctly, I think I would miss out on starting from the current date, Aug 14th.

    Does that make sense or am I not following your idea correctly?

    Thanks,

    -Bob

  • 08-15-2013 05:43 AM In reply to

    Re: sort calendar items ascending but only need top 5 from todays date

    What happens if you reverse the sort before copying over the 5 items?

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.