People picker validation to exclude users in SharePoint

Watch this demo video of how you can use data validation on a person/group picker control on an InfoPath 2013 form to exclude SharePoint users who are from a specific department from being selected in the people picker control.

You cannot add validation rules to the people picker control in InfoPath, because the option to do so is disabled. However, you can still work around this limitation of InfoPath to create solutions where data that is entered into a people picker is validated.

Recipe 73 of InfoPath 2013 Cookbook 2 teaches you the basic technique to add data validation to a people picker in InfoPath 2013, and the following InfoPath 2013 with SharePoint 2013 video demonstrates how you can extend recipe 73 to apply any type of data validation to a person/group picker control by adding data validation to a people picker control on an InfoPath form to allow users to select people who are not from a specific department that has been defined through SharePoint user profiles.

Brief instructions to create such a solution are available in the InfoPath 2013 Cookbook 2 Club.

InfoPath 2013 with SharePoint 2013 video tutorial transcript

Here I'm in SharePoint 2013, where I've already published an InfoPath form template to this SharePoint form library, so if I click new document to add a new form, you'll see that an InfoPath form will open displaying this drop-down list box control on it containing the names of departments, and this people picker control.

I've added data validation to the people picker control to allow only users to be selected who are not from the department selected in the drop-down list box control. So for example, if I select Accounting here, I don't want users from the Accounting department to be entered in the people picker control.

The users that I'm going to be testing with are: Jane Doe who as you can see is in the Development department, John Doe who is also in the Development department, and Clovis who is in the Accounting department.

I'll start entering some names here... and when I click Check Names, you'll see that this error message will appear saying "One or more users you selected are from Accounting", which is true because Clovis is from Accounting. So then if I go and click Submit, this error message will appear. So I cannot submit the form until I correct the issue, which in this case would be to remove Clovis, and then you'll see that the error message will disappear.

If I add John Doe and I'll add Clovis back, and then I'll select no department on top here, you'll see that we won't get any error messages. And as soon as I select Development, which is the department of Jane and John, you'll see again "One or more users you selected are from Development". So then again I would have to remove Jane and John to get the error message disappearing, so that I can submit the form.

So that is how you can extend recipe 73 of InfoPath 2013 Cookbook 2 to allow any type of data validation to be applied to a people picker control on an InfoPath form.

See more InfoPath 2013 tutorial videos »

 
 Subscribe for updates via RSS or Email

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services