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).
So we want to use SharePoint user profile services to do this.
then proceed to next , select UserProfileByName and un select the Automatically load.Now you have created the connection.
Note : – If we Query the data source with out parsing any parameters it will load the current user detail.
then click Ok. now you have configured the data connection. Now you have Form Load rule for query user profile service.
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 Valuein 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.
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.
User profile data coming as key value pairs. Ex:-
thus we need to pick the correct data from the Value. Thus we need a filter Display Name from the Value.
after that click Ok. After several Clicks you can see below dialog.
Now you have two actions (one for query and other for Set PreferredName to DisplayName field in the person/group picker control )
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)
Then proceed with the same method and finally give filter as AccountName , which we assignPreferredName earlier.
Now you are having three actions in the Form Load and now you are done.
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