Friday, March 1, 2013

SharePoint – Web Service Requests in InfoPath Forms (Classic to Claims)

Without writing code, you can populate User Profile Service (UPS) information into your fields in InfoPath forms. This process is clearly defined in the following blog. However, as this works perfectly, in the classic-based authentication there are several modifications that will need to be made, to fully utilize the forms, as a result of product limitations caused by Claims-based authentication.

Firstly, a Secure Store ID will need to be created in Central Administration (Manage Service Applications), you’ll need to assign the Target Application ID, and add the Target Application Administrators which would ideally need to be a generic ID that never expires, and the members that are mapped to the credentials defined. You’d need to then set the credentials on that domain account for the secure store target application. Lastly, under Central Administration (General Application Settings), and InfoPath Forms Services, the option to ‘Allow user form templates to use authentication information contained in data connection files’ is selected.

To re-mediate any issues with the data connections previously created while in classic (that utilize web services), you will need to download the previously created data connections from their respective data connection libraries, and open them using any text editor. You’ll notice that the UDCX files, are purely XML. Modify the XML, such that the following information is included. What this allows, is for impersonation to allow the user accounts accessing this form, to be able to get the correct data from the web services.

    
 
Once this change is made, simply re-upload and publish your data connection file, into the data connection library associated with your InfoPath Form Library. Once you complete this action then re-open your InfoPath Form template. If you were providing information on a button press, form load, or form submit operation, you’d simply modify your existing actions to include the following details. You would need to add another action to set a field’s value, and when the dialog appears, select the drill-down beside the field textbox.


Within the next dialog, click the drop-down and select your respective web service. In the image below, the data connection was named GetUserProfileByName, and you will need to select the field AccountName and press OK.


and in the value field, simply enter userName(), or add it by the function entry under Users.

Lastly, you’ll need to perform a query using a data connection action, utilizing the data connection associated with the web service request. These two major items need to be before your other field-based actions as it’ll then associate the requests with your ID, and populate your information correctly.

Below is a sample image, which illustrates what the actions should look like, in the correct order, to acquire the First Name of the user. These field values for the individual user profile service attributes, is listed in the blog article talked about above.


Post a Comment