Auto-populate the person/Group picker from the current user on InfoPath 2007/2010/2013

If you need to fill the default value of the person/group picker with the current logged user when the form is loading, there is an easy way to do it. The following steps will show you how to do it:
  1. Create a web service connection to get the user profile information from the current user:
    • Manage Data Connections -> Add -> Receive Data -> SOAP Web Service:
    • Include the location of the SOAP Web service definition:
      • http://YourServer/_vti_bin/UserProfileService.asmx?WSDL
    • Select GetUserProfileByName
    • Make sure the "Automatically retrieve data when form is opened" option is ticked.
  2. Add a Person/Group picker field to your info path form


 3. Create a new action rule in the "Form Load" to run under a condition, if needed, i.e: Add the current user into the Person/Group picker field when the Person/Group picker field is blank: 
DisplayName is blank

4. Set the Person/group picker DisplayName to PreferredName




5. Set the Person/group picker AccountId to AccountName



  6. Set the Person/group picker AccountType to "User"

set User Type



Now, when the form is loaded the person/group picker will be populated automatically with the current user information.
The person Group/picker field can disable for editing by users, you just need to add a formatting rule that always complies, so users cannot edit the field.

You can promote the user details to the SharePoint form library (i.e: if you are using a custom workflow and you need the user email address or you need the user name/surname).

To promote the "person group picker" field, select the "DisplayName" field if you need the Name/Surname of the user, or the "AccountId" if you need the Login Id (You can use the Login Id to get the email address using a custom SharePoint workflow). For the both promotions do not forget to select "first" within the "function" drop down list.




Comments

  1. Thank you! Thank you! THANK YOU!

    ReplyDelete
  2. Worked perfectly, thank you

    ReplyDelete
  3. I was able to get this to work so when my user opens the form, their name is populated. They complete the form and save. The list that is populated does not show their name, its blank. When I export my list to excel for reporting the names are missing so I dont know who the task is assigned to. How do I fix this?

    ReplyDelete
  4. Hi, When you are promoting the User field you have to to pick up the "DisplayName" field instead of the whole repeating section, then you select "first" wihin the "function" dropdown list

    ReplyDelete

Post a Comment

Popular posts from this blog

How to convert fields in lower case/upper case within Info path forms

How to auto save a browser enabled info path form every X minutes in Sharepoint 2007, 2010 and 2013