Skip to main content

How to set Current User Name to InfoPath Person/Group Picker

This method also use for get User Profile Information such as First Name , Last Name , Office and etc.

In generally we can not set a default value to InfoPath Person/Group Picker. On the other hand we can not get Current Username in the InfoPath. (Yeh it is true that we can use userName() function. But this will return the Current User Account ID not the name).

image

So we want to use SharePoint user profile services to do this.

  • First we need to  create a user profile connection.
    • Thus First go to Manage connection and click add connection.

image

    • Then go to receive data option and SOAP Web service and specify the User Profile Service URL. The URL will be something like (http://sever/sites/site/_vti_bin/UserProfileService.asmx). This is depends on your site or site collection. if it is a site collection you can omit /sites/site/ part from your URL.

image

then proceed to next , select UserProfileByName and un select the Automatically load. Now you have created the connection.

image

  • Now you have User Profile connection to receive profile data.

image

  • For an example we will design a form like below. You need to set the current user automatically when the form load.

image

  • Then Go to the Form Load Rules.

Note : – If we Query the data source  with out parsing any parameters it will load the current user detail.

  • Thus now we are going to query the data connection (GetUserProfileByName) in the form load. thus Go to Form Load rules and then set a  Action as Query for data and select the UserProfile Data Connection.

image

then click Ok. now you have configured the data connection. Now you have Form Load rule for query user profile service.

image

for InfoPath person picker to identify the user we need to set DisplayName  as well as AccountID.

Now we are going to set the display name for the control. so Add a new Action Set a Field’s Value in the form load and Click the DisplayName in the date picker control field in the Main Data Connection. You can follow below steps to do that.

 

image

then we need to assign the value for displayname.thus we need to get that value form the data connection “GetUserProfileByName” that we already queried in the form load. thus now it contains user profile data for the current user. only we need to fetch the value related to Display name.

image

User profile data coming as key value pairs. Ex:-

  • value[“PreferredName”] = Some Name
  • value[“AccountName”] = Some Value
  • value[“FirstName”] = Some Name

thus we need to pick the correct data from the Value. Thus we need a filter Display Name from the Value.

image

after that click Ok. After several Clicks you can see below dialog.

image

Now you have two actions (one for query and other for Set PreferredName to DisplayName field in the person/group picker control )

image

Now you are done with setting the DisplayName of the Person/Group Picker Control. Then we need to assign the AccountID. so go to very first step. and then add a new action to assign the value for AccountID. So select the AccoutID (Very first step, we selected DisplayName earlier)

image

Then proceed with the same method and finally give filter as  AccountName , which we assign PreferredName earlier.

image

Now you are having three actions in the Form Load and now you are done.

image

Now if you preview the form you can see values coming. You can also use following name parameters to load other user profile data (FirstName, LastName) to controls (Ex- TextField , Combo) as well.

UserProfile_GUID
AccountName
FirstName
LastName
PreferredName
WorkPhone
Office
Department
Title
Manager
AboutMe
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

Comments

Albert Henry said…
I did get this worked with Account ID and Display Name but the thing is that when I save data, it is not getting submitted to SharePoint.
b said…
@Albert Henry,

I did not exactly understand your point. If you are not matched any filed to list entire document is submitting to the SharePoint
Ahmed Hlabba said…
Hi ,thanks for your post , it works great in preview mode but when i piblished form i get an error ID 5566

An entry has been added to the Windows event log of the server.
Log ID:5566

Correlation ID:8a7023db-9e56-45ae-9832-51193a4d23c2
AprilD said…
i have a list for my team members made up of people picker columns. i draw from that list to set the values in a separate list/infopath form (also people picker). the data does NOT save/publish to the list. just like Albert Henry says perhaps? i'm going to instead have to get rid of the people picker i think and just have it be text fields in the 2nd form (the consumer).
b said…
@AprilD,

People picker is a complex control which hold the data as semicolon separated (Ex- DisplayName;ID;Email). So what you can do it you can save the entire thing to a text field or accoutID to a text field to retrieve data in future.
Anonymous said…
Hello

this works on now form but not on an edit form - I have the need to fill the people picker also in an edit form

how to do this?

robert
Anonymous said…
I got the same error as @Ahmed Hlabba. Does anyone know how to resolve this error ID 5566?
b said…
@Anonymous,

Does it submit any value or nothing

Popular posts from this blog

How to Customize New Item Form to take parameters from Query String in the SharePoint 2010

In here I'm going to explain how to customize the SharePoint Item From to take parameters from Query String and set them as default values using SharePoint designer. Using this you can open a new Item From by providing parameters as query string. For an example you can customize one item Display form and taking query String Parameter from that and view New Item view for another list by providing default values using the Query String.     Steps Open the SharePoint designer and go to list and libraries and open the list that you want. Click the New and create a New Insert View by providing the name of the view.   Then created one will come to the list. then click and open the view. Then default New Item Screen will be loaded as follows. Then Delete the default list view and make that empty. You can delete the controls by selecting the area in the design view, If it fully cleared you can view the following message from the designer. Then go to SharePoint...

How to Link Two List and Create a combine view in the SharePoint 2010

In this way you can join multiple list together and can create a combine view. for an example assume that you are managing a list for some events. And also you are having a participants in separate list. Thus you want to join the two list and create a composite view. SharePoint 2010 allows you to create this kind of view using  Linked Data Source. in this approach you can create your own custom list in the SharePoint. How to Create a Linked Data source Go to SharePoint designer and  go to the link called data sources. And Click the Linked Data Source button in the ribbon. Then SharePoint designer will prompt following kind of a dialog. In there add two list, that you wan to linked together. I'm adding airline schedule and booking list. those are the two list that i wan to merge. then click next. And it will guide you another screen. it will ask you to select either Merge Merge use to combine list which are having same columns definition. for and example we can s...

Complete guide to Install SharePoint in a Three Server Farm using AutpSPInstaller

This article will be divided to three sections Setting up the Environment and Service Accounts Getting Ready with AutoSPInstaller Online Configuring the XML using Online Editor and Installation Setting up the Environment and Service Accounts AutoSPInstaller Online is one of a great project that facilitate Automated SharePoint installation including Sharepoint 2010, 2013 and 2016. Auto SP Installer provides a powerful way to deploy and configure a single-server development environment to multiple-server SharePoint farm. Reference: https://autospinstaller.com/ Before doing anything we will set up the environment for SharePoint three server Farm. Will name these servers as SPWFE - Share Point Front End Server SPAPP - Share Point App server SPDB - DB server Please find the reference for SharePoint minimum requirement and practices from https://docs.microsoft.com/en-us/SharePoint/install/install-sharepoint-server-2016-across-multiple-servers For the the medium segregation, we have to create...