Skip to main content
Nintex Community Menu Bar

On one of my Nintex forms I want users to enter a series of (variable number) of event dates and other data related to those events in a repeated section. I would like to have users enter the rows in chronological order on the date field, from earliest date to the latest date. I know that normally you can just compare dates like they’re numbers and dates further in the future are treated as greater than dates less far in the future or in the past, but I’m having trouble getting the rule right so that it compares to the control element on the previous row (if present).

Like I want date(row N) > date(row N-1) for N>1

This is for Sharepoint on Prem 2019.

I have tried forcing it on the last row with a validation rule:

and(equals(currentRowNumber(dateField),rows(dateField)),lessThan((dateField),max(dateField)))

then invalidate, but it doesn’t seem to work, the rule inside only takes the field on the current row, it doesn’t look at other rows.

 

I have also looked at sorting it in workflow, but I want to keep the related data from the other fields connected as well and the sorting operation on Collection operations only works on one Collection at a time, you can't reorder another Collection B based on the reordering when sorting collection A, which makes the problem quite complex.

Anyone have any ideas how to do this?

Hi ​@BobR,

Just trying to understand what you are trying to achieve here.
Correct me, please, if I am wrong, but it sounds like you just want the repeating section to display in a sorted manner. And it doesn't matter if it's at the time of creation or after the item is submitted and the form reopened. Am I on the right track?
I don't think this can be achieved in the form unless you use a classic form and some custom JavaScript. This just leaves manipulating the XML of the repeating section in a Workflow.

Attached is a workflow that will sort your repeating section for you.
Connect the Repeating section to a multiple-line text column configured as plain text and use that as the workflow's input.
Then write back to that column at the end of the workflow.
When the form is reopened after the workflow has run, the repeating section will be in date order.
I tested this using a date control as the first control in the repeating section.

 


That’s indeed what I’m trying to achieve. The main challenge for me is that the repeating section has multiple fields. A date field that I want to sort by and another string field. The data in the string field has to be moved along with the date field in the sorting process, such that the string data stays connected with the dates it belongs to. That’s the part I’m struggling with, because as far as I can tell you load up the data from separate fields in separate collection variables and sorting the one with the date field leaves me unable to rematch it back with the data from the string field.

 

As I’m writing this, one thing I’m coming up with to try is to create a collection variable that’s joined up of all the data in the repeating section, leading with the date, sort that, and then separate the data row by row with regular expression and rebuild it to XML, but it seems fairly complicated with multiple For Each loops to run through. If you know a simpler method please let me know


Hi. 
 

Based on your requirements I believe the workflow I have provided will fulfill your need. 


You’re right, it works. The only issue is the date sorting being a bit off because of the internal date format from the repeating section being in MM/dd/yyyy HH🇲🇲ss format, so it doesn't sort properly across different years. Would there be a way to sort it on an yyyy/MM/dd HH🇲🇲ss format (or similar) instead?


Hi ​@BobR,

The date format in the XML depends on the region setting of the SharePoint environment.
I tested with MM/dd/yyyy. I'm sorry; I didn't think of that one. 
I still think this is possible, but as you said, the workflow would be more complex.
An alternative would be to use some sort of middleware, to which you send the XML, and it sorts it and sends it back.


Got it. I modified your workflow by extracting the dates from the collection with Regular Expressions, converting the date format, then sorting, then converting the date formats back in the same way, and it works now. Thanks for all the help


Reply