various shenanigans.

Calculating Business Days for Nintex Form

Had a request to calculate several deadline or due dates from one specific date to autopopulate fields on a Nintex form. This also had to calculate business days only excluding holidays and weekends.

I am using the moment.js library and moment-business-days plugin.

Upload those .js files to your site assets folder and add the full URL to the Custom Javascript includes on your form Settings.

Make sure to add Client ID JavaScript variable names to your date fields.

NWF.FormFiller.Events.RegisterAfterReady(function () {
    var tday = '11-25-2021'; // These lines add holiday dates. 
    var xday = '12-24-2021'; // Moment.js calculations will exclude these days.
    moment.updateLocale('us', {
        holidays: [tday, xday],
        holidayFormat: 'MM-DD-YYYY'
    });
 
NWF$('#' + pUp).change(function () { // Execute when my master deadline date changes. Update other date fields.

// Calculate Add/Subtract by Calendar days 
// var newDate =  moment(NWF$('#' + pUp).val(), 'MM/DD/YYYY').add('days', 7);
// var newDate =  moment(NWF$('#' + pUp).val(), 'MM/DD/YYYY').subtract('days', 7);
// var newrd = moment(newDate).format('MM/DD/YYYY');
// NWF$('#' + rework).val(newrd);
// NWF$('#' + rework).change();

// Calculate Add/Subtract by Business days			
var newdate = moment(NWF$('#' + pUp).val(), 'MM/DD/YYYY').businessAdd(7)._d;
// var newdate = moment(NWF$('#' + pUp).val(), 'MM/DD/YYYY').businessSubtract(7)._d;
var newrd = moment(newdate).format('MM/DD/YYYY');
NWF$('#' + rework).val(newrd);
NWF$('#' + rework).change();
});
});

In my specific scenario, I am back-populating or subtracting business/holiday days based on a master due date (highlighted).

Close Bitnami banner
Bitnami