hagarm
Design Dabbler

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

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

0 Kudos
Reply
7 Replies
emha
Automation Master
Automation Master

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

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);
}


Reply
hagarm
Design Dabbler

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

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?

Reply
emha
Automation Master
Automation Master

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

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?

Reply
hagarm
Design Dabbler

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

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

Reply
emha
Automation Master
Automation Master

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

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

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;‍‍‍‍‍‍


‍‍‍‍‍‍‍‍‍
Reply
hagarm
Design Dabbler

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

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.

0 Kudos
Reply
emha
Automation Master
Automation Master

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

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;
    });
});
0 Kudos
Reply