SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have:

  • A Person Picker in an InfoPath form
    • Set to current user by default using SharePoint userprofileservice
  • A SharePoint List with a person column
    • this list is available in my InfoPath form as a datasource

I want to verify that a person selected is present in the list.

This can be done on submit or change of data in the Person Picker I don't mind.

The form is being submitted to a SharePoint form library and I do have options for creating a task in some way for an admin to clean up bad forms once they get there but I would like to avoid that.

(SharePoint & InfoPath 2010)

share|improve this question
up vote 2 down vote accepted

You can do that using code in the form. Find below how can be done.

var nav = this.MainDataSource.CreateNavigator();

//Obtain the Account Id from the people picker
var userId = nav.SelectSingleNode("my:myFields/my:RequesterGroup/pc:Person/pc:AccountId", NamespaceManager);

var web = SPContext.Current.Web;
var userList = web.Lists["YOUR LIST HERE"];

// Here I would use a CAML query instead, but works for the example
foreach (SPListItem item in userList.Items)
    var current = item["USER FIELD"] as SPFieldUserValue;
    var user = current.User;

        // The user is part of the list, do something and return

I hope it helps.

share|improve this answer
In the end I created a sharepoint group and used the standard person picker. It allowed that form to remain without any code. – gordatron Feb 23 '13 at 10:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.