How to add a data connection to a SharePoint list or library in InfoPath
This step-by-step InfoPath tutorial explains how to add a data connection to a SharePoint list or library and then view the structure of the secondary data source in the Data Source task pane.
Problem
You have an InfoPath form template and would like to add a data connection to a SharePoint list or library to it.
Solution
Use the Data Connections menu item on the Tools menu in InfoPath to add a data connection to a SharePoint list or library.
Discussion
You can accomplish this functionality as follows:
- In SharePoint, ensure that you have a list or library that you can use.
- Launch InfoPath and create a new Blank InfoPath form template.
- On the Tools menu, click Data Connections.
- On the Data Connections dialog box, click Add.
- On the Data Connection Wizard dialog box, select Create a new connection to:, select Receive data, and click Next.
- On the Data Connection Wizard dialog box, select SharePoint list or library, and click Next.
- On the Data Connection Wizard dialog box, type in the URL to the SharePoint list or library you want to use, and click Next.
- On the Data Connection Wizard dialog box, if the SharePoint list or library is not already selected, select the list or library you want to connect to, and click Next.
- On the Data Connection Wizard dialog box, select the fields you want the data source to contain, and click Next.
- On the Data Connection Wizard dialog box, click Next.
- On the Data Connection Wizard dialog box, type in a name for the data connection or accept the default name, and click Finish.
- On the Data Connections dialog box, click Close.
Once you have added the Data Connection to the SharePoint list or library, the form template will contain a secondary data source. You can view this secondary data source as follows:
- On the View menu, click Data Source.
- On the Data Source task pane, select the secondary data source from the Data source
drop-down list box as shown in the following figure:
Figure 1. Selecting a secondary data source from the Data Source task pane in InfoPath. - Once you've selected the secondary data source, you can view its structure in the Data Source task
pane as shown in the following figure:
Figure 2. The structure of the secondary data source from the Data Source task pane in InfoPath.
Now you can use the secondary data source to the SharePoint list or library on the form template by binding controls to it or by programmatically accessing it and its data through code.
Related InfoPath Articles:
