Conditional Rules According to a Choice Field

  • 30 April 2018
  • 8 replies
  • 3 views

Badge +3

Hi Nintex experts, this is my 1st day join the community and here is my 1st question

in my list i have these cloumns:

1- a choice  drop-down List (Item1, Item2,.....)

2- Date-and-Time filed 

On the form itself i have another current Date- and-Time field

the List date and time field need to be compared with the current date and time according to the choice from the drop-down list

for Item1,  the entered DATE should be >= 2 days from current date

 for Item 2, the entered TIME should be >= 2 hours from current time

for any other item, no need for any validation

===============================================


8 replies

Badge +16
  1. Add a calculated value control
    1. Formula:  dateAddDays(Current Date, 2)  < --- Note dateAddDays and Current Date are all selected on the tabs in the expression builder
    2. Name:  expTwoDaysAway
  2. Add a calculated value control
    1. Formula:  formatDate(dateAddHours(Current Time, 2), "HH:mm")  < --- Note formatDate, dateAddHours and Current Time are all selected on the tabs in the expression builder
    2. Name:  expTwoHoursAway
  3. Add a calculated value control
    1. Formula:  formatDate(DateandTime, "HH:mm")  < --- Note "DateandTime" is the name of my date and time control on the form
    2. Name:  expSelectedTime
  4. Add validation to your date/time control as follows:  and(equals(Choice, "Item 1"),lessThan(DateandTime,expTwoDaysAway)) with the message along the lines of "If Item 1, the date must be >= two days from today"
  5. Add validation to your date/time control as follows:  and(equals(Choice, "Item 2"),lessThan(expSelectedTime,expTwoHoursAway)) with the message along the lines of "If Item 2, the time must be >= two hours from now"

If the above is not completely right, hopefully should give you an idea of direction?

Badge +3

Thank you Cassy for your help.

i think i have a weak knowledge to follow your guidelines using the Calculated Value Controls

what i did,

1- I created a Form Variable

   Name: varRequestDate

   Type: Integer

   Formula: dateDiffDays(Date,{Common:CurrentDate})

2- in my Dat/Time  Field i created a Rule

   Name: DateValidationRule

   Rule Type: Validation

   Condition: varRequestDate <2 

this worked fine but added the condition for 2 days for all the choices.

I was thinking to build  a Case formula saying:

case1: if RequestType = type1 then Date - CurrentDate should be>=2days

Case2: if RequestType = type2 then time -CurrentTime should be >= 2hours

else, for any other RequestType, no control to be applied

can i still using the form variables and rules to achive this?

many thanks

 

Badge +16

Not a form variable but a calculated value control.  you can find these on the toolbox under "General"

Badge +3

Dear Cassy

i followed it step by step, the situation now is:

1- when i select the item with the 2 days validation check, it stuck with any date i select, and keep prompting the error message 

2- if i select thye item with the 2 hrs check, it accepts  the item regardless what was the entered time

please find the attached screenshots of all created rules and calculated values.

expTwodaysAwayexpTwoHoursAwayexpSelectTimeDateValidationRuleTimeValidationRule

Badge +16

OK a few things

format should be "HH:mm"

and I send old screengrab of expTwoHoursAway:

Where you have {Item Property: Date} that should be your Date named control - otherwise your rule is looking at the saved value, not the selected value on your form.

Badge +3

Dear Cassy,

yes the named control in my form is Date

i formatted the formula same way u sent now, but still the same issue, that the 2 days check is ON all the time, while the 2 hrs check is always OFF 

215140_pastedImage_1.png

Badge +16

are you adding these as rules on the controls?

I will send you my list and form exports via email so you can compare.

Badge +3

i received the list, it is working fine with the 2 days with Item 1 validation, but it is also accepting any date and time for Item 2 without any validation

Reply