Share via


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.

UserProfile_GUID

FirstName

LastName

PreferredName

WorkPhone

AccountName

Department

Title

Manager

AboutMe

Office

PersonalSpace

PictureURL

UserName

QuickLinks

WebSite

PublicSiteRedirect

SPS-Dotted-line

SPS-Peers

SPS-Responsibility

SPS-Skills

SPS-PastProjects

SPS-Interests

SPS-School

SPS-SipAddress

SPS-Birthday

SPS-MySiteUpgrade

SPS-DontSuggestList

SPS-ProxyAddresses

SPS-HireDate

SPS-LastColleagueAdded

SPS-OWAUrl

SPS-ResourceAccountName

SPS-MasterAccountName

Assistant

WorkEmail

CellPhone

Fax

HomePhone

 

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!

Comments

  • Anonymous
    January 01, 2003
    Hi can it implement in infopath, like i want to display the list items in infopath itself. if i select emp id, should display automatically all the info related that employee in infopath itself.

  • Anonymous
    January 01, 2003
    I have the same question as m.Riston from 29 Jul 2013 5:48 PM:

    "Is it possible to pull in the, say 'Title' field of another user that is determined based off of a people picker? Say I'm trying to create a form that I'm selecting someone's new supervisor and I want to populate that user's 'Title' or 'WorkPhone' field after I select it using a people picker. Is that possible?"

    https://social.technet.microsoft.com/Forums/en-US/1e4117d2-652b-442c-9ff1-2153eeedde69/how-to-get-user-profile-service-information-on-user-other-than-current-user?forum=sharepointcustomization

  • Anonymous
    January 01, 2003
    how to change the Form Load rule's condition to DisplayName is blank? I can only see the AccountName. Thank you

  • Anonymous
    January 01, 2003
    Is it possible to pull in the, say 'Title' field of another user that is determined based off of a people picker? Say I'm trying to create a form that I'm selecting someone's new supervisor and I want to populate that user's 'Title' or 'WorkPhone' field after I select it using a people picker. Is that possible?

  • Anonymous
    January 01, 2003
    whenever the form is opened again either to view or edit, it displays the current users information instead of the value of the person who completed the form in the first place. please help

  • Anonymous
    January 01, 2003
    Hi Jason - I had forgotten I had that problem, too. Change the Form Load rule's condition to DisplayName is blank and that should work.

  • Anonymous
    April 04, 2012
    Firstly thanks for the information. It works great. However i have an issue whenever the form is opened again either to view or edit, it displays the current users information instead of the value of the person who completed the form in the first place. Any feedback would be appreciated.

  • Anonymous
    May 16, 2012
    Hi, thanks for pointing me in the right direction on this.  I was going around in ever-decreasing circles.  However, it's a case of one-step forward, two back at the moment!  I can preview the form, and everything is fine, i.e. my form is populated with user data and manager data, as expected, but as soon as I publish to the SP Server, I get the following error on running the form.   An error occurred querying a data source. Click OK to resume filling out the form. You may want to check your form data for errors. Show error details I am a Farm Administrator, so jsut wondered if you had any ideas what is going on.  If I click on OK, the form appears, BUT none of the data is populated as it is in preview.   HELP!  Thanks

    • Anonymous
      May 29, 2017
      I am facing the same problem of you, did you find a solution for it?
  • Anonymous
    June 21, 2012
    The comment has been removed

  • Anonymous
    November 08, 2012
    Firstly thanks for the information. It works great. However i have an issue whenever the form is opened again either to view or edit, it displays the current users information instead of the value of the person who completed the form in the first place.

  • Anonymous
    January 09, 2013
    Hi,  Thanks for the article and it is very useful information. I am having the issue that the look up field has to load more than 5000 records and it takes more time to load the form and sometimes it is loading the partial data. Is it anyway to modify the query or need to do something to fix the issue?

  • Anonymous
    January 28, 2013
    Really good, works perfect first time (even though I have no idea what I have actually done).

  • Anonymous
    March 26, 2013
    Thank u...Very usful

  • Anonymous
    May 16, 2013
    very nice ..very helpful.

  • Anonymous
    May 24, 2013
    Follow the steps and no value to populate in preview. Any idea?

  • Anonymous
    June 26, 2013
    I new to this and I've already created a form in InfoPath and connected it to the forms library.  I have several fields that I want to auto-populate.  Where do I start use the information provided?

  • Anonymous
    July 24, 2013
    Im trying to create a form in which the intial form is create but then I want to create a workflow inwhich the form is sumitted and then a nother form within the worklfow appears and the information that was in the previous form appears in the secondary form. Is this posisble?

  • Anonymous
    August 13, 2013
    Thanks Anne! Here's a related post on InfoPath 2010 Best Practice Querying User Profile Web Service: www.sharepointbreak.com/.../infopath-2010-best-practice-querying-user-profile-web-service

  • Anonymous
    August 15, 2013
    Hi Anne, Great article. Would you know how to get the Full Name (First and Last Name) of the Manager. In your example I can see that you're getting the Manager field as domainuserid. I'm looking for a way to get the first and last name. Any help is much appreciated. Thanks, KP

  • Anonymous
    January 16, 2014
    Thank You. Really Useful

  • Anonymous
    May 12, 2014
    user profile values are not populating in the infopath form after publishing it to sharepoint 2010.
    Please let me know where i am going wrong.

  • Anonymous
    June 09, 2014
    Instead of using accountName as blank, i used another field that I know was going to be blank until the user filed it out. So mine was SiteURL is Blank. Thank my actions were query by GetUserProfile and Set data fields.

  • Anonymous
    August 27, 2014
    Will this work with anonymous access enabled on the server?

  • Anonymous
    September 25, 2014
    Nice its very helpful

  • Anonymous
    September 30, 2014
    Nice article. I can get the User Name in the preview, but I am getting an error after publishing. Help me please.

  • Anonymous
    November 07, 2014
    Thanks so much for this information. I have been working on getting this completed for over two weeks now. The form populates only my name on the field, not the person who submitted the form. I've tried several ways to set up rules for this but the result is always my own name showing up on the form. Is there anything that I should be doing differently? your help is greatly appreciated :)

  • Anonymous
    November 19, 2014
    very helpful

  • Anonymous
    November 27, 2014
    Thank you for your detail post. I could implement this easily with your fabulous screenshots

  • Anonymous
    February 06, 2015
    One question, this works for Sharepoint online too?

  • Anonymous
    February 13, 2015
    I'm having the same problem as Andrew Brooks above - was there an easy fix?

  • Anonymous
    March 04, 2015
    I have the same question as Steven Norman - "Is it possible to pull in the, say 'Title' field of another user that is determined based off of a people picker? Say I'm trying to create a form that I'm selecting someone's new supervisor and I want to populate that user's 'Title' or 'WorkPhone' field after I select it using a people picker. Is that possible?"

  • Anonymous
    April 05, 2015
    Hi, I did this in the server environment, but is it possible for SharePoint 2013 online also, where we work on cloud ??

  • Anonymous
    April 17, 2015
    Awesome....configured Profile Service to pull more data from AD. Worked like a charm. Great work.

  • Anonymous
    June 16, 2015
    HI Anne and All,

    Iam newbie to Infopath, current iam working on infopath office 365 form. Our app is used to save first name, Last name...Status field values into Sharepoint list ...so far every thing is fine. Now if any one click on Users First Name...A new form is open and display all saved vales of that user...How to proceed onthis...your help is very much needed..Thanks In advance...

    Do the needful

  • Anonymous
    July 03, 2015
    First of all thank you for such a comprehensive set of instructions. I too am having the same problem as Andrew Brooks, everything is working perfectly until i publish to SharePoint and then i get the error "An error occurred while trying to connect to a Web service."

    Does anyone know why this may be happening and what i need to do to fix?

  • Anonymous
    July 15, 2015
    Thank you very much Anne, great information.
    I'm trying to implement what you wrote in Sharepoint 2013 environment. I select the user from the AD but the query rules do not work and cause Infopath to crash. Although very unlikely, is it possible that Name="Department" syntax has changed in SP 2013?
    Thanks,
    Tolga

  • Anonymous
    September 30, 2015
    Hi, Im new in infopath and sharepoint, but i have create a form in infopath to auto populate user information and i convert the connection and all things good, but when users create form the sharepoint doesn't keep the user information and when other user open the same form it the current user information.....And i don't want it because i need workflow??Please need help

  • Anonymous
    October 02, 2015
    Thank you for this superb guide!

  • Anonymous
    October 21, 2015
    Like - Kevin Doherty 3 Jul 2015 1:17 PM -- First of all thank you for such a comprehensive set of instructions. I too am having the same problem as Andrew Brooks, everything is working perfectly until i publish to SharePoint and then i get the error "An error occurred while trying to connect to a Web service." Does anyone know why this may be happening and what i need to do to fix?

    I have now recreated similar info that would be found in the UserProfileService by putting this information in a list. Problem is I cannot figure out how to pull the data from the different columns. So far my workaround is at a dead-end. -Edward.compudoc@gmail.com

  • Anonymous
    December 14, 2015
    Great article - thanks!

  • Anonymous
    July 27, 2016
    Hi,What happen if my email don't populate on the preview? Please help

    • Anonymous
      October 20, 2016
      nevermind, I figure it out, thanks
  • Anonymous
    August 15, 2016
    Can we get or set data from external content type list ?

  • Anonymous
    October 19, 2016
    Dear all,How can i get Description field value????Thanks in advance

  • Anonymous
    May 29, 2017
    I applied it step by step. But when I publish it and I opened it in sharepoint,This error was occurred.An error occurred querying a data source. Click OK to resume filling out the form. You may want to check your form data for errors. An error occurred while trying to connect to a Web service.Correlation ID:a857f69d-136e-70b2-822b-5cc24f315c93--------------------------------------------------------------------------------An error occurred while trying to connect to a Web service.Correlation ID:a857f69d-136e-70b2-822b-5cc24f315c93

  • Anonymous
    June 06, 2017
    As I web site possessor I believe the content matter here is rattling excellent ,appreciate it for your hard work. You should keep it up forever! Best of luck.

  • Anonymous
    June 08, 2017
    I was suggested this website by my cousin. I'm not sure whether this post is written by him as nobody else know such detailed about my trouble.You're amazing! Thanks!

  • Anonymous
    June 08, 2017
    797158 208240i always enjoy to do blog hopping and i stumbled upon your blog ."~; 224032

  • Anonymous
    June 12, 2017
    Hello There. I found your blog using msn. This is an extremely well written article.I'll be sure to bookmark it and return to read more of your useful information. Thanks for the post. I will definitely return.

  • Anonymous
    June 14, 2017
    Hurrah, that's what I was exploring for, what a information! existing here at this website, thanks admin of this web page.

  • Anonymous
    June 16, 2017
    Hi all, here every one is sharing these kinds of familiarity, so it's pleasant to read this website,and I used to visit this webpage every day.

  • Anonymous
    July 17, 2017
    I have read a few just right stuff here. Certainly worth bookmarking for revisiting. I wonder how a lot effort you place to create this kind of fantastic informative website.

  • Anonymous
    January 24, 2018
    Thank you for this tutorial with very clear steps, its really helped me a lot.