InfoPath form Contact selector

 The Contact Selector consists of 3 data nodes:

  • DisplayName
  • AccountId
  • AccountType


Each is just a text field.  When you publish your form, you have the option of promoting one or all of the fields. DisplayName only contains the PreferredName attribute of the User Profile Database, which is typically in the form of LastName, FirstName, but it depends on your AD setup.

AccountId is the most valuable field, because it contains the user's domain name in the form of domain\username (i.e. microsoft\userId).  If you promote this field to SharePoint, then this value is immediately usable for sending workflow emails in SharePoint Designer.  I do this all the time.  Also, that value can have the domain portion stripped out and be used to query the GetUserProfileByName web method to retrieve the selected user's profile info, including Email Address, Manager, Department, and many other attributes stored in the profile database.

Since these are text fields, they do not match the data type of a SharePoint People Picker, so you cannot bind any of them directly.  What you have to do is retrieve the selected user's email address from the previously-mentioned web method, store it in a hidden field, promote that field, then use a SharePoint Designer workflow to "Set Field in Current Item" and set the People Picker field to the value of the user's email address, because that's what those field types accept as input.

To retrieve the email address of the user in the Contact Selector, use my method:

InfoPath - Get user information without writing code (extended)

The key for you will be that when you do the part right before Figure 15, you need to set the AccountName query parameter to the username value from AccountId.  You do this by setting that field to this function substring-after(AccountId, "\").  This will strip the username off of the domain name so that the username is sent to the web service.  For instance, microsoft\ccobb would be stripped down to ccobb and then used to query the WS.

Popular posts from this blog

Adding Contact Selector Control to InfoPath form

Adding Validation to a Custom NewForm.aspx in SharePoint & Redirect

How to add to Sub-Sub Menu in SharePoint