Nintex for SharePoint Forum
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
I am trying to get the max date in a repeating row section in a Nintex Form (v2013). Does anyone have any suggestions?
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);
}
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?
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?
I must admit, I'm a javascript novice. I have tried a few things, with no success!
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;
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.
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;
});
});