While designing InfoPath forms for applications, at times the need arises to fetch user information from SharePoint site and to have some check name validation.
There are 2 ways of achieving the same
1. By using web service UserProfile.asmx
2. By using Contact Selector ActiveX control
In this article, I will focus on Contact Selector ActiveX control
Step1: In Microsoft Office InfoPath 2007, from the Controls pane, drag a Contact Selector control onto your form.
Step2: Double-click the control. In the Contact Selector Properties dialog box, on the Data tab, for Field or group name, type a name for the control. Click OK
Step3: Design the appearance of the control as you want.
After these steps now you need to bind this control with data.
Configuring the Contact Selector Control Schema
To data-bind the Contract Selector control, you must create a data schema within the control that represents each contact. Create the schema for each contact in the following format.
'<'DisplayName>user display name'<'/DisplayName'>'
'<'AccountType>user or group type'<'/AccountType'>'
Following are the elements of the schema:
- Person Root element of the schema that represents one contact.
- DisplayName Display name of the contact in Windows SharePoint Services or Active Directory directory service.
- AccountId Domain and user account identifier for this contact.
- AccountType Type of account that this contract represents
To configure the schema for a Contact Selector control
1. In Office InfoPath 2007, insert the Contact Selector control into your form, as described earlier.
2. Select the Contact Selector control, and in the Design Tasks pane, click Data Source.
3. Click the arrow next to the Contact Selector name, and on the drop-down menu, click Add.
4. In the Add Field or Group dialog box, create a group with the following properties:
a. For Name, type Person.
b. For Type, select Group.
c. Select Repeating.
d. Click OK.
5. Click the Person group, and then on the drop-down menu, click Add.
6. Add a field with the following properties:
a. For Name, type DisplayName.
b. For Type, select Field (element).
c. For Data Type, select Text (string).
d. Select Repeating.
e. Click OK.
7. Click the Person group, and then add two more fields as described in the previous step.
a. For Name, type AccountId for the first field and AccountType for the second field.
b. For Type, select Field (element) for each field.
c. For DataType, select Text (string) for each field.
d. Select Repeating for each field.
The only drawback of this control is that with internet explorer’s High Internet security settings, it doesn’t work. The work around is to use web service (UserProfile.asmx).
thanks to Pushpinder for the inputs.