We have a form that we've built using InfoPath 2010 that will publish to a SharePoint 2010 site. We would like to have the form check against the list when a user enters a unique value in a field (such as an employee ID #) and return any data associated with that ID if it finds any and pre-populate form fields. So, for example, let's say John Smith went and filled out this form today. He enters his ID at the first page and hits 'Submit'. The form would check against the list column of ID to see if his is there. Since he hasn't come here before there isn't a record yet. So he goes through and fills out the fields of the form and submits it. A month later, he forgets if he filled in a field or not and comes back to the first page that he has to enter his ID. After he enters it and hits 'Submit' the form again queries the list and finds his previous submission and pre-populates the fields on the next page. He can then change or add data and submit. Hopefully, it would just update that existing record instead of creating a new one but that's a 'nice-to-have'. Any ideas or help would be greatly appreciated! Thank you!

  • Is the lookup list on the same site collection? Nov 16, 2012 at 21:45
  • Yes. I believe so. Nov 16, 2012 at 22:20

1 Answer 1


This is certainly do-able, but this question is rather broad. Basically, when you query against the ID, if you get results back you would set a boolean that you would maintain. When the user actually submits the form, if the boolean is set to say that a list item was found you would update the list item, otherwise you would create a new list item.

You'll want to get familiar with CAML queries. A query against a UserID list column, for instance, would look like:

string userID = GetTheUserID();
SPList list = GetYourList();

SPQuery myQuery = new SPQuery();
myQuery.Query = "<Where>" +
                  "<Eq>" +
                    "<FieldRef Name='UserID' />" +
                    "<Value Type='Text'>" + userID + "</Value>" +
                  "</Eq>" +
SPListItemCollection returnedData = list.GetItems(myQuery);

Let me give you a few links to get you started here:

CAML Query Schema

Introduction to Programming in InfoPath 2010

  • Thanks rjcup3! We'll look into it and let you know if we need more help or if we get it to work. Thanks again! Nov 21, 2012 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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