Without seeing your existing Rule or Form, it should still be relatively straight forward.
Consider the Rule that is hiding the Panel and Controls.
If "X" is True => Hide Panel
That means that if you wanted to make a validation rule inside of the panel to consider it's visibility, you'd need to reverse the logic!
If "X" is False => Validate Control
Additionally, because you want validation to fail if the field is empty you can combine that idea with the first part:
If "X" is False AND This Control is Empty => Control is Invalid!
In practice the rule would look something similar to:
YesNo_Control_Reference && isNullOrEmpty(People_Control_Reference)
Here is a simple mockup using a Yes / No checkbox and a Panel with a People Picker Control inside of it:
Here is the Rule for the Panel:
(Notice the "!" at the beginning of the Control Name Reference. That 'inverts' the boolean value of the control. So an Unchecked Control will equal true instead of false, and a checked control will equal false instead of true. This way the Panel stays hidden until we check the box!)
Now we just need to add a rule to our People Picker Control:
If you click on the little 'F of x' (aka: f(x)) button, you'll be presented with the Formula Builder where you'll have access to all of your Control References and Runtime Functions which you can easily insert into your formula as shown.
(Note: For a Control to show up in the 'Named Controls' tab, it must be given an actual name otherwise it will not be there. In this case I have named the Yes/No Control as 'Show_Panel')
Now when you Preview the form, you'll see no Panel:
Until you check the 'Show Panel' box:
If you try to save without putting something in there, you'll be greeted with an error:
Inserting a valid person though will allow you to pass the validation test:
I hope that this helps you along your way.
@MegaJerk
Thanks for that. I have a panel that unhides based on multiple conditions:
Form your post I guessed that perhaps I need ot apply the validation to the people picker inside the panel, so, building on the rule that shows the panel, I added an AND clause to check the peoiple picker but without success:
or(contains(BProjectCategory,"ProjectTypeA"),or(contains(BProjectCategory,"ProjectTypeB"),or(contains(BProjectCategory,"ProjectTypeC"),and(isNullOrEmpty({Self})))))
The rule makes the field show in red but after entering a name in the people picker, it still doesn't validate.
I have used this structure on another rule that worked fine but can't get this to work.
Ok I got this to work.
My panel is hidden using this rule:
or(contains(ProjectCategory,"ProjectA"),or(contains(ProjectCategory,"ProjectB"),or(contains(ProjectCategory,"ProjectC"),and(not(contains(RiskBox,"Low"))))))
(When the ProjectCategory is not one of the three values AND RiskBox is Low, it shows.
On the poepl picker control I added a new validation rule and used the code below. I had to repeat th conditions as I don't have another control that becomes true/false when the panel is unhidden.
or(contains(BProjectCategory,"Core Research Project"),or(contains(BProjectCategory,"Internal Capability Funding"),or(contains(BProjectCategory,"HVM Catapult Funding")))) && isNullOrEmpty({Self})
This is now working.
Thanks @MegaJerk: I needed the bit in your example where you added the rule to the people picker control and
&& isNullOrEmpty({Self})
Awesome to hear! Glad that it worked out!
Hi all,
need to seek your expertise.
I have a Nintex form with two fields as follows:
Accessby : drop down field
Approval : people field (hidden by default, shown only based on the value of Accessby)
- I need to hide Approval by default and show Approval field only when Accessby is showing 3 values e.g. "Cat1" "Cat2" "Cat3" (applied hide rule which is working fine)
- When Approval field is shown, I want to make sure users fill in at least one person and not leave as empty field.
I tried the following at the Rule section of the Approval field, but the system does not do Step 2 above, what is the correct formula to ensure that the Approval field is not empty when shown? :
- and(isNullOrEmpty({Self}), or(equals(Accessby, "Cat1"), equals(Accessby, "Cat2"), equals(Accessby, "Cat3")))
- isNullOrEmpty({Self}) and (Accessby == "Cat1" or Accessby == "Cat2"or Accessby == "Cat3")
- isNullOrEmpty({Self}) && (Accessby == "Cat1" || Accessby == "Cat2" || Accessby == "Cat3")
- "Show_panel" does not show up in my system? wonder why?
When I tried isNullOrEmpty({Self}) alone, the system immediate prompt me that the Approval field is empty even though the Approval field is hidden (note that I did not tick the "validate when hidden")