How to Create an InfoPath Form to Auto Populate Data in SharePoint 2010

I have been working on a SharePoint 2010 site and the site owner wanted a form that would auto populate the current users information. Is this possible? Sure, but I’m not a developer so I had to figure out a different
way. This is where InfoPath 2010 comes in - although I’ve never worked with that product either. :-)

Researching on the Internet, I found some really good posts that I used to accomplish my task:

The SharePoint site is a repository of projects and people who sign up to help with the projects. We have the following lists:

  • Skills: pre-defined list of products/skills (i.e. SharePoint, Exchange, Development)
  • Projects: a list that is populated when someone starts a project
  • Resources: a list that is populated when someone adds themselves as a resource to work on projects

This post will provide step by step instructions on how to use InfoPath 2010 to create a form that will automatically populate users e-mail, first and last name, title, phone number, and manager.

Resources List

Create a custom list and create the fields as shown. Notice we are using “Single line of text” for the email instead of “Person or Group”.

The original “Title” column was renamed to E-Mail and requires unique values because I didn’t want someone to add themselves more than once.

The Skills column is a Lookup type that allows multiple selections tied to the Skills list.

The Title column is a new column is for the title of the resource.


Under General Settings, choose Advanced Settings. We need to change Item-Level Permissions and Attachments – all other settings are to stay at their defaults. Users should be able to read all items but only create and edit their own items; additionally we aren’t allowing attachments because they aren’t necessary for this list.

After you have the columns created for the list, it is time to customize the input form.

Customize InfoPath Form

From the Resources list, click the List tab then Customize Form.

The customize Form button will automatically launch InfoPath 2010 and will look similar to this. The red asterisks in the Fields pane indicate required fields. You can see the exact correlation on this form and our SharePoint list fields from above.

Enable SOAP Web Services

We need to enable the SOAP Web Services so we can pull information from the User Profile Service. Click the Data tab, From Web Service, From SOAP Web Service.

In the Data Connection Wizard, type the URL of your site and add /_vti_bin/UserProfileService.asmx to the end as shown and click Next

After the connection is made to the web service, scroll down to find the operation called GetUserProfileByName and click Next

Click Next on the Parameters dialog box

Click Next on the following screen

Enter a name for the data connection and click Finish.

On the right side under the Fields pane, select Show Advanced View

So far we have created our custom list, started customizing an InfoPath form and added the User Profile Service web services to the form. Now we have to create rules on what to do when the form loads.

Create Rules

Make sure you have the Data tab selected then choose Form Load. We will be using the Rules: Form Load section to create the rules and actions. Select the New button and choose Action. Our first rule is going to check the Account Name of the currently logged on user.

Account Name of Current User

Type a name for the rule under Details for then click the link under Condition that says “None – Rule runs when form is opened

In the Condition dialog box, click the arrow next to myFields and choose Select a field or group…

In the Select a Field or Group dialog box, change the Data source to GetUserProfileByName (Secondary)

Under myFields, expand queryFields until you find and select AccountName then click OK

Change the Conditionis equal to” to “is blank” and click OK

Query for Data: GetUserProfileByName

In order get populate our form, we need to query the User Profile Services web service. In our Form Load data box, click Add to run an action and choose Query for data. Change the Data connection to GetUserProfileByName and click OK.

Next we need to get the data from the User Profile Services web service to populate our form with the current users’ data.

E-Mail Data

Click Add and choose Set a Field’s value

Click the expander  next to Field.

Ensure you are on the Main Fields then expand MyFields and select E-Mail and click OK

  1. Back at the Rules Details dialog box, click the Value icon  (this gets tricky :-))
  2. Insert Formula dialog box, click Insert Field or Group
  3. On the Select a Field or Group, change Fields to GetUserProfileByName (Secondary) and expand dataFields until you can select Value and click Filter Data
  4. On Filter Data, click Add
  5. In Specify Filter Conditions, change Value to Select a field or group
  6. In the Select Field or Group, and choose Name under PropertyData and click OK
  7. In the third box, change to Type Text… and type in WorkEmail and click OK on all the dialog boxes to create the rule

Let’s check to make sure we did this right. Click the Preview icon in the top left of the screen and you should see your email address populated in the E-Mail field

Remaining Rules

Follow the steps under E-Mail Data to populate the rest of the fields. When you are done, your form should have these rules applied.

Keep in mind that you are “GETTING” the data from the User Profile Service web service by using GetUserProfileByName (Secondary) to “PUT” data into your fields in the InfoPath form. Set the field on your form by getting the value and name
from the User Profile Service.

Default Profile Properties

This is a list of the default profile properties used by the User Profile Service that can be pulled and put into the InfoPath forms.









































Publish the Form

After you have all the rules in place and have verified they work correctly, you can publish your form back to SharePoint. Simple click the X in the top right corner and choose Save and Publish.

The form will be saved to SharePoint, InfoPath 2010 will close and you will be taken back to the list from where you started customizing the form.

From here, click Add New Item. The Resources - New Item dialog box will open and you will see all the fields populated with the current users information.

The only thing the user has to do now is to select their skills and save the form.

I hope this helps others and a special shout-out to Itay Shakury and Clayton Cobb!