Add validation rules to a people picker in InfoPath 2013

This InfoPath video is a demonstration of how you can use a custom validation rule to prevent users from selecting more than 2 people from a people picker control on an InfoPath form.

In recipe 73 of InfoPath 2013 Cookbook 2, you'll learn how to add data validation to a people picker control on an InfoPath form, so that users can select a maximum of only 3 users from the person/group picker control.

Get more solutions from InfoPath 2013 Cookbook 2 which is available on
Watch next video: SharePoint Designer workflow loop through people picker

InfoPath demo video transcript:

In recipe 79 of InfoPath 2013 Cookbook, you learned a technique you can use to validate the data that is stored in a multiple-selection list box control. That same technique you can apply to a person/group picker control to validate its data.

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 as soon as the InfoPath form opens, it will display this person/group picker control on it.

I've added data validation to this people picker control so that users can only select a maximum of 2 people from it, so I'll start entering a couple of names here: jane.doe and john.doe. And then when I click away, you'll see that we're still all good.

As soon as I enter a third name, I'll take clovis, and click away, you'll see that the person/group picker control will display this validation error saying that "No exact match was found." This is coming from the people picker control itself, because clovis does not exist as I've typed him in here on this server. So I'll select the correct name, and then click away again. And then you'll see that the only validation error that is left is this custom validation error that I've added to the people picker control.

Now I can go ahead and try to save the form. When I do so, you'll see this error message pop up saying that "This form contains validation errors." But I can still go ahead and save the form if I wanted to. However, if the form has been enabled to be submitted, and I click the Submit button, you'll see this error appear saying that "InfoPath cannot submit the form because it contains errors." And I can only click OK, so I cannot submit the form.

Basically, what I would have to do is, I would have to delete one of these names, so that we get only 2 people or less in the people picker control. And then I can go ahead and click the Submit button to successfully submit the form.


Related InfoPath Demo Videos:


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. 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.

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013