Skip to main content
Nintex Community Menu Bar

Calculated column formula to calculated value

  • March 6, 2018
  • 10 replies
  • 51 views
  • Translate All

Forum|alt.badge.img+3

I know that calculated columns don't work on Nintex forms. So my question is, how would I get the following calculated column formula converted into a calculated value on a form?

Calculated column formula: 

=TODAY()+(7-WEEKDAY(TODAY(),2))

10 replies

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • March 7, 2018

This should replicate what you're trying to achieve. 

formatDate(dateAddDays({Common:CurrentDate}, (7-(new Date ().getDay()))), "d")‍

Breaking it down into parts: 

//{Common:CurrentDate} === 3/7/2018

//new Date ().getDay() === 3 (aka: Wednesday)



formatDate(dateAddDays({Common:CurrentDate}, (7-(new Date ().getDay()))), "d");

// translated...

// formatDate(dateAddDays(3/7/2018 12:00AM, (7 - (3))), "d");

// translated...

// formatDate(dateAddDays(3/7/2018 12:00AM, 4), "d");

// translated...

// formatDate(3/11/2018 12:00AM, "d");

// translated...

// 3/11/2018
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Translate

Forum|alt.badge.img+3

For my understanding, what is "new Date" and ".getDay?" Where are these coming from? 

Translate

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • March 7, 2018

That's just basic javascript (JavaScript getDay() Method or Date.prototype.getDay() - JavaScript | MDN). 

Calculated Value control Formulas are just evaluating javascript at the end of the day, so you can use it inside of there with no problems (most of the time). 

Translate

Forum|alt.badge.img+3

I figured. However, not getting a result when I preview it, hence I asked. This is what I have: 

213723_pastedImage_1.png

Translate

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • March 7, 2018

Make sure that the view options in the properties of your calculated control are set to ReCalculate value on View:

213595_pastedImage_1.png


Otherwise you won't be able to preview it. 


Translate

Forum|alt.badge.img+3

Hmmmm. Mine seems to still be blank...

213724_pastedImage_1.png

Translate

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • March 7, 2018

Please copy and paste the code in my first reply into your formula field. You have a typo after the getDay where you have left off the invoking parentheses. 

Translate

Forum|alt.badge.img+3

My man! Perfect! Preciate it!!

Translate

Forum|alt.badge.img+3

nmarples‌ Do you know if there is a way to restrict a datepicker to not allow for future dates. I was trying to come up with an expression within the Date/Time control to do this, but I think its going to have to be done with javascript. 

With that said, I think I'm close. I know I can do the following or something similar: 

$('#datepicker').datepicker({ maxDate: 0 })

which would essentially not allow for any date past 'today.'

I'm having trouble converting this to being used on the form. I think I would need to store it in the javascript variable and reference it, but I'm not sure.

Translate

Forum|alt.badge.img+3
  • Rookie
  • July 15, 2018

Hi,

sorry to hijack this thread but as I have an issue similar to this but have a formula on premise which works and want it to work in o365, I thought I'd add it.

It calculates from the current date the date of the previous friday:

=IF(WEEKDAY([Current Date])<6,[Current Date]-(11-WEEKDAY([Current Date])),[Current Date]+5-WEEKDAY([Current Date]))

However, I'm a bit stumped as to how to imp[lement it in the samesimilar way as to how you solved this one with your formula.

Any help would be much appreciated.

Regards

Julian

Translate