Mittwoch, 3. Oktober 2012

Allow only certain people in a people picker

How to allow only certain users to be chosen from the people picker


Some time passed without any posts as I had to get my job done ;-)

And while working on a small project I saw a ... let's say not so optimal list form.

There was a field where the user had to enter the email address of a responsible manager. But only certain managers were to be selected here. So what they made was just creating a radio button list with all managers which were also placed in a certain group.

Their amount was around 30. So you can imagine how the form looked like. Of course they have could just use a dropdown list. Still it wouldn't be very good-looking and easy to use.

Furthermore it was desired that the administrators of the SharePoint site only need to add managers to the group. The field selection should be populated automatically based on the list. This could have been done by coding, but I didn't like that idea.

So I came up with my own one which was just using integrated SharePoint features.

So what do we need?

Actually only two things:
  1. a user group which includes all the people that should be selectable.
  2. a field in the list where the person is actually going to be selected

Let's get it done

  • For the field where the person is to be selected, set its type to "People Picker".
  • When creating/editing the people picker field in the list settings you have the option to change some of its properties.
  • One of them is where the pickable people come from. In many enterprise environments the Active Directory users will be the default.
  • But instead you want the group with the people to be selectable, so you replace all active sources by your desired group.
  • That's it. You can save your changes.

What's happening now, when users try to enter a wrong person which is not in the group, they can't save the item (unless you set the field to be optional).
Furthermore you can use functionalities like entering email addresses or names and the automatic user check finds the person which fits the inputs.

Another huge advantage is that you simply need to add a user to the group and he will automatically appear in the people picker. So you don't have to worry about editing a field as well.

I hope this could help you, if not or if you just want to say "thank you", please leave a comment.