Hi, is there any way to calculate the day of the week and put it in a field on a Nintex form? I need to display certain fields depending on the week day on which a form was created.
Solved! Go to Solution.
var d = new Date();
var weekday = new Array(7);
weekday = "Sunday";
weekday = "Monday";
weekday = "Tuesday";
weekday = "Wednesday";
weekday = "Thursday";
weekday = "Friday";
weekday = "Saturday";
var n = weekday[d.getDay()];
Afterwards you only need to populate "n" to your control.
That is a very good idea. The only problem is that I can't work out how to write that value back to a field on my form! Do you know how to do that? I'm completely puzzled by it.
thath shouldn't be a big problem:
Query that control from your JS code and set the value. Something like that should do the trick:
NWF$("#" + weekdaytxt).val(n)
You can do this directly on the form and then save the value you want into a sharepoint column.
You see Wednesday on this form. It is a calculated control that is connected to a SharePoint column. So the value that is in the New Form will be saved to SharePoint.
Just drop a calculated control on the form, set the connected to dropdown, and add the formula.
I used the formatDate formula on the Common context Current Date
formatDate(Current Date, "dddd")
"dddd" provides the name of the day of the week.
See the blog Date and Time Format Strings - Quick Reference Guide for more options on formatting. You can do "dd" for 04 being 4/4/18 today and "ddd" for Wed