Rule for People Picker


Badge +5

Hi,

I have another question, how to add a rule on people picker?

for example if I choose Individual Nominee , the people picker field should allow user to all only one person.

If I choose Team Nomination then the people picker should allow multiple users names.

Thanks In Advance


14 replies

Userlevel 5
Badge +14

it's not possible to restrict people picker control to dynamically change at runtime number of allowed entries.

you can however write a validation rule that could check whether single person or team is selected along with number of entries in people picker control.

have a look on following post how to determine number of entreis in people picker control https://community.nintex.com/message/62289-re-people-picker-field-validation?commentID=62289#comment-62289 

Userlevel 5
Badge +14

While you cannot restrict the Maximum Entries value on the control during runtime, you can certainly validate against it. 

If you have two (2) controls

Choice Control

   Options:

  1. Individual
  2. Team

Name: target_group

People Picker

   Required: Yes

   Maximum Entries: 25

   CSS class: myPeoplePicker

   Name: target_selector

You'll be able to use the following rule to throw a validation error when you have selected Individual on the Choice Control and more than one (1) entree for the People Picker Control. 

(target_group === "Individual" && NWF$(".myPeoplePicker .ip-item").length > 1);

The results should be as follows: 

Individual selection + more than (1) entry will fail.

But a Team selection passes the test

I hope this helps. 

Badge +5

Than you Very much !!!! that really made magic happy.png

Userlevel 5
Badge +14

Ah! Excellent! Great to hear! 

Badge +5

HI,

 All of a sudden this rule is not working on my form any more.

 what could go wrong?

could you please let me know?

Thanks,

Rama.

Userlevel 5
Badge +14

Out of curiosity, which version of SharePoint are you using?

I can't evaluate it right now, but should be able to do some testing later tonight. 

Badge +5

SharePoint 2013

Userlevel 5
Badge +14

And is there any particular strange behavior that is happening other than that it is no longer working?

As in, it works with Individual but not Group, or the other way around, or neither? 


Badge +5

No!! I have applied it only for individual nominee( like if user click individual and put more than 1 person in people picker then the validation rule should be applied).

Now, the form is not validating any more.

The strange thing I notice is.. when I figured the validation rule is not working any more I tried to pull the older version of the form ( where my validation rule for the people picker field is working) and checked it is not working either!

Please let me know if I explained clearly.

Thanks,

Rama.

Userlevel 5
Badge +14

That is interesting. One last thing. Could you take a screenshot of your form if you don't mind, or tell me if the control is inside of a Repeating Section or some other control (like maybe a panel)? 

It might help to recreate the situation when I try to later. 

Badge +5

I was  using Panel for the other fields but not these fields ( contribution and List the name of Nominees)

Please let me know if you need more information.

Userlevel 5
Badge +14

Interesting. 

I just tested in my environment (SP2016) and everything seems to be working just fine. 


205962_pastedImage_2.png

205963_pastedImage_3.png

The only difference I see between our code is the class that you're using ".mypeoplepicker" and not ".myPeoplePicker"

205964_pastedImage_4.png

Make sure that the class name you have for your People Picker control actually matches that. 

205965_pastedImage_5.png

Badge +5

That's right  class names were not matching !!!! (  I did not realize plain.png).

Thank you for looking into this!! I really appreciate your help!!!

Thanks,

Rama.

Userlevel 5
Badge +14

Good to hear that it is now working for you! 


Reply