Skip to main content
Nintex Community Menu Bar
Solved

Working out the weekday on a Nintex form

  • Mar 27, 2018 10:31 AM UTC
  • 9 replies
  • 360 views
  • Translate All

Forum|alt.badge.img+5

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.

Best answer by andrewg

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

View original

9 replies

Forum|alt.badge.img+16
  • Mar 27, 2018 1:29 PM UTC

Let SharePoint do that work, add a calculated field on your list

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Mar 27, 2018 1:33 PM UTC

But I want it to be available on a newly created form, and that doesn't work. So I'm stumped.

Translate

Forum|alt.badge.img+11
  • Nintex Partner
  • Mar 27, 2018 3:26 PM UTC

Hi Alice,

if JavaScript is an option you can use the custom javascript section of your form.

var d = new Date();
var weekday = new Array(7);
weekday[0] =  "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var n = weekday[d.getDay()];‍‍‍‍‍‍‍‍‍‍‍

 

Reference: JavaScript getDay() Method 

Afterwards you only need to populate "n" to your control.

Cheers

Philipp

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Mar 29, 2018 7:33 AM UTC

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.

Thanks.

Alice.

Translate

Forum|alt.badge.img+11
  • Nintex Partner
  • Mar 29, 2018 5:50 PM UTC

Hey Alice,

thath shouldn't be a big problem:

  1. Drag a single line textbox onto your form where you want to display the value
  2. Configure the control ("Advanced" tab)
    1. Store Client ID in JavaScript variable = Yes
    2. Client ID JavaScript variable name = some simple string

Query that control from your JS code and set the value. Something like that should do the trick:

NWF$("#" + weekdaytxt).val(n)‍

Best Regards

Philipp

Translate

rhia
Nintex Partner
Forum|alt.badge.img+15
  • Nintex Partner
  • Apr 2, 2018 10:24 PM UTC

Just note that this won't work on mobile -- but if you don't need mobile, this is a great way to do it!

Translate

Forum|alt.badge.img+17
  • Nintex Partner
  • Answer
  • Apr 4, 2018 5:06 PM UTC

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

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Apr 9, 2018 9:03 AM UTC

Thank you Philipp, that's really helpful.

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Apr 9, 2018 9:18 AM UTC

Wow this is also really helpful - thank you Andrew

Translate