cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

How can I default a date field to the next Monday date?

Jump to solution

In SharePoint, the field is already configured as a calculated date with this formula: =Today+6-WEEKDAY(Today+4)

That works in the standard edit mode when adding a item, but that does not work in Nintex (Expression)

0 Kudos
Reply
8 Replies
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

You can use following JavaScript to set a date control default to Next Monday.

NWF$(document).ready(function()
{
var d = new Date();
var twoDigitMonth = ("0" + (d.getMonth() + 1)).slice(-2);
var currentDate = (d.getDate() + (1 + 7 - d.getDay()) % 7) + "/" + twoDigitMonth + "/" + d.getFullYear();
NWF$('#' + fldDateClosed).val(currentDate);
});

Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

Thank you Lakshmi!

Can you tell me where/how I insert the JavaScript in the date control ?

The control is currently connected to a date column for a list in SharePoint.

In Nintex, I right-click on Settings. Then in Control Settings - Date/Time dialog, I can't find a place to insert the JavaScript other than the Expression in the Advanced section.

I'm very new to Nintex, so I appreciate your help.

Regards!

0 Kudos
Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

Go to the form settings to input the custom JS

After that open the control settings of the date control and add the js variable

Is that date formatted correctly for you?

Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

That worked perfectly, thank you!

0 Kudos
Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

Hi Chadd,

Is it possible to change the date format to mm-dd-yyyy  ? It is currently set to dd-mm-yyyy but the system is set to mm-dd-yyyy, so it is showing wrong values in the calculated date field.

I tried using the fn-FormatDate function but doesn't work for me.

Thanks for your help.

Justo

0 Kudos
Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

Hey Justo,

The format of the date is dependent on the JavaScript.

I'm not totally sure, I'd have to play around with it, but switching the twoDigitMonth and.getDay variable around might fix it.

(You may have to paste this in Notepad first, then copy it)

NWF$(document).ready(function()
{
 var d = new Date();
 var twoDigitMonth = ("0" + (d.getMonth() + 1)).slice(-2);
 var currentDate = twoDigitMonth + "/" + (d.getDate() + (1 + 7 - d.getDay()) % 7) + "/" + d.getFullYear();
 NWF$('#' + fldDateClosed).val(currentDate);
});

Give it a try, if it doesn't work, I can try to recreate the scenario in my environment. Let me know.

-Chadd

0 Kudos
Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

That did not work...

Thanks!

0 Kudos
Reply
Workflow Hero

Re: How can I default a date field to the next Monday date?

Jump to solution

That's weird. I just tried it and it worked for me.

0 Kudos
Reply