Best way to get max date in repeating row section of Nintex Form?

  • 8 December 2016
  • 7 replies
  • 3 views

Badge +4

I am trying to get the max date in a repeating row section in a Nintex Form (v2013).  Does anyone have any suggestions?


7 replies

Userlevel 5
Badge +14

eg. like this

place a calculated value control outside of repeating section and its formula to

(DateInRS) is name of date control within repeatinh section)

ConvToDate(Math.max.apply(null,DateInRS))

place following javascript into form's settings/Custom javascript

function ConvToDate(val){
  return new Date(val);
}


Badge +4

Thanks for the suggestion Marian.

This would work for me if the date field is going to be shown/selected by user.  In my case, I have a hidden date field, that is updated via javascript when a couple of other fields are updated.  I'm using it as a timestamp.  When I create a calulated field using the Math.max.apply function, it only updates if my date field is displayed and tabbed through.  Suggestions?

Userlevel 5
Badge +14

then it should be much easier, shouldn't it?

since you populate dates in single RS rows with javascript you have full control over what values are being written there. so you can maintain some javascript variable you max value.

or do I still miss something?

Badge +4

I must admit, I'm a javascript novice.  I have tried a few things, with no success!

Userlevel 5
Badge +14

keep trying on , finally you will find a way that will work happy.png

one of plenty possible way may look like this

// define some custom variable in NWF$ namespace and set it some base value
var NWF$.myMaxDate = new Date(1900,0,1);

// check and update max Date if needed
if (NWF$.myMaxDate < new_date_vale)
    NWF$.myMaxDate  = new_date_value;‍‍‍‍‍‍


‍‍‍‍‍‍‍‍‍
Badge +4

My hidden 'datestamp' date field in my repeating section  uses javascript that looks like this:

NWF$(document).ready(function(){  NWF$(".control-class").on('change', function(e) {var timestamp = new Date();NWF$(this).closest('.nf-repeater-row').find('.nf-date-picker').val(timestamp.format('MM/dd/yyyy'));});});

function ConvToDate(val){
return new Date(val);

I use '.control-class' in other fields within the repeating section, specifed in  'control CSS class'.

Can you please give me an example of how to integrate a custom variable like you are suggesting above?

Thank you in advance.

Userlevel 5
Badge +14

not sure I understand what you mean with 'integrate a custom variable'...

I just assume you want to save max timestamp value.

then it might look like this.

 var NWF$.myMaxDate = new Date(1900,0,1);

NWF$(document).ready(function(){ 
    NWF$(".control-class").on('change', function(e) {
        var timestamp = new Date();
        NWF$(this).closest('.nf-repeater-row').find('.nf-date-picker').val(timestamp.format('MM/dd/yyyy'));
        if (NWF$.myMaxDate < timestamp)
                        NWF$.myMaxDate  = timestamp;
    });
});

Reply