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

Conditional Rules According to a Choice Field

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

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

Labels: (1)
Tags (1)
0 Kudos
Reply
8 Replies
Workflow Hero

Re: Conditional Rules According to a Choice Field

  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?

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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

 

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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 

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

are you adding these as rules on the controls?

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Conditional Rules According to a Choice Field

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

0 Kudos
Accept as Solution Reply