Integrating InfoPath 2010 with the SharePoint 2010 Data Connection Library
Summary: Learn how to use Universal Data Connection (UDC) files in a Data Connection Library (DCL) to provide data connection settings to Microsoft InfoPath 2010 form templates for use in both client and server forms.
Applies to: InfoPath 2010 | Office 2010 | SharePoint Server 2010 | Visual Studio Tools for Microsoft Office
In this article
Lab Objectives
Lab Setup and Requirements
Scenario
Exercises
Conclusion
Additional Resources
Contents
Lab Objectives
Lab Setup and Requirements
Scenario
Exercises
Conclusion
Additional Resources
Lab Objectives
In this lab, you will learn how to:
Create a data connection library for Microsoft SharePoint Server 2010.
Create a Universal Data Connection (UDC) file to specify a SharePoint list data connection.
Use InfoPath 2010 to design a form that uses the settings contained in a data connection library.
Set up a drop-down list to show only unique values from a data connection.
Lab Setup and Requirements
To complete this lab, you must have the following:
InfoPath 2010 installed on a client computer.
Access to a SharePoint Server 2010 as a farm administrator or site collection administrator.
InfoPath Forms Services running on an installation of SharePoint Server 2010.
Alternatively, you may install both InfoPath 2010 and SharePoint Server 2010 on the same computer.
Scenario
Jane at Contoso Pharmaceuticals wants to create a simple form to enable the sales team to submit feedback about the sales events announcements. These announcements are located on the team SharePoint Server site.
Exercises
The following exercises describe how to create and test a simple form. First, you will create the data connection library. Then, you create the connection settings file. Finally, you create the form and test the connection.
Creating a Data Connection Library
The first step is to create a data connection library in a site collection. The data connection library will provide a location to put the shared data connection settings file.
To create a data connection library
Browse to an SharePoint Server 2010 site on which you have at least Design permissions. If you are on the root site, create a new site before you continue with the next step.
On the Site Actions menu, click More Options.
On the Create page, click Library under Filter By, and then click Data Connection Library.
Type DCLLab for the library name, and then click Create.
Copy the URL of the new data connection library.
Creating a Connection Settings File
After you have created the data connection library, you can then create a new Universal Data Connection (UDC) file. Later on, you will create a form that contains an announcement list; InfoPath will use the UDC file to locate data to fill that list.
To create a new data connection file to point to the Announcements list on your site in InfoPath
Open InfoPath Designer 2010, click Blank Form, and then click Design Form.
On the Data tab, click Data Connections, and then click Add.
In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.
Click SharePoint library or list, and then click Next.
Enter the URL of the SharePoint site, and then click Next.
In the Select list or library list, select Announcements, and then click Next.
On the next two pages, click Next.
On the last page of the wizard, click Finish to return to the Data Connections dialog box.
In the Data Connections dialog box, click Convert to Connection File.
In the Convert Data Connection dialog box, enter the URL of the data connection library that you previously copied (delete "Forms/AllItems.aspx" and anything following it from the URL), enter the name DCLLab for the data connection file at the end of the URL, and then click OK.
InfoPath Designer will take several moments to convert and save the data connection file to the library.
To confirm that InfoPath Designer successfully converted the data connection
Select the name of the converted data connection in the Data Connections dialog box, and examine the Details section. When you are finished, click Close.
Close InfoPath Designer 2010 without saving the changes to the form.
Ordinarily, you would continue designing the form after you define the data connection. For this demonstration however, you start designing the form from scratch in the next procedure.
Browse to the SharePoint data connection library, click the drop-down next to the name of the data connection (DCLLab), click Approve/Reject, click Approved, and then click OK.
Browse to the Announcements list, and then click Add new announcement.
Enter multiple announcements for testing; be sure to include at least one duplicate announcement.
Creating a Form to Test the Connection
In the previous step, you created a Universal Data Connection (UDC) file that specified where you can get data for an announcement list. In the following step, you will create an InfoPath form that references that connection information. InfoPath enables you to create any number of forms that reference the UDC file; for the purpose of this lab however, one will suffice. Be aware that updating the UDC file to point to a different location will automatically update all of the forms that reference the UDC file.
The following steps show how to create a form that uses the connection information in the UDC file.
To add a reference to the UDC file to a new form template
Start InfoPath Designer 2010, click Blank Form, and then click Design Form.
On the Data tab, click Data Connections, and then in the Data Connections dialog box, click Add.
On the first page of the Data Connection Wizard, select Search for connections on a Microsoft Office SharePoint Server, and then click Next.
Click Manage Sites, and then in the Manage Sites dialog box, click Add.
In the Site Details dialog box, in the first field, type the path of the site that contains your data connection library (for example, http://MyServer/MyTeamSite).
(Optional) In the second field, type a display name to identify this site.
Click OK, and then click Close.
In the Site list, select the site that you defined.
Expand the entry for your data connection library, select the UDC file that you uploaded, and then click Next.
Choose the following columns to include in the list, and then click Next:
Title
Modified
Select the Store a copy of the data in the form template check box to cache a copy of the current data in the form for an offline user, and then click Next.
Note
Announcements data is unlikely to change frequently. Therefore, caching the data offline ensures that the user always has the data available, without significant risk of the data being out of date.
Click Finish, and then click Close.
In the next procedure, you will add some text, a Drop-Down List Box, and two Option Button controls to the form so that it resembles the following form template shown in Figure 1.
Figure 1. Creating a simple form to test the data connection
To add controls that display data from the UDC file to the form
Double-click the drop-down list, and then on the Control Tools Properties tab, click Edit Choices.
Under the List box choices, select Get choices from an external data source.
Select the Announcements list data connection that you added in the previous exercise from the Data source list.
Click the button next to the Value field, and then select the ID field.
Click the button next to the Display name field, and then select the Title field.
Select the Show only entries with unique display names check box, and then click OK.
Save the form.
After you have finished designing the form, test your solution.
To test the form
On the Home tab, click Preview Form.
Open the drop-down list; observe that InfoPath populated the list from the Announcements list.
Note
InfoPath has filtered the entries so that only unique entries appear in the list.
Close the preview window and save the form.
Conclusion
In these exercises, you learned how to create a data connection library on SharePoint Server 2010. You also learned how to create a Universal Data Connection file in InfoPath Designer 2010 to define a SharePoint List connection. In addition, you learned how to design a form that takes data connection settings from the UDC file. Finally, you learned how to set a drop-down list to show only unique values from a data connection.
Additional Resources
For more information about how to develop with InfoPath, see the following resources: