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.

ADVERTISEMENTS

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:

  1. In SharePoint, ensure that you have a list or library that you can use.
  2. Launch InfoPath and create a new Blank InfoPath form template.
  3. On the Tools menu, click Data Connections.
  4. On the Data Connections dialog box, click Add.
  5. On the Data Connection Wizard dialog box, select Create a new connection to:, select Receive data, and click Next.
  6. On the Data Connection Wizard dialog box, select SharePoint list or library, and click Next.
  7. On the Data Connection Wizard dialog box, type in the URL to the SharePoint list or library you want to use, and click Next.
  8. 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.
  9. On the Data Connection Wizard dialog box, select the fields you want the data source to contain, and click Next.
  10. On the Data Connection Wizard dialog box, click Next.
  11. On the Data Connection Wizard dialog box, type in a name for the data connection or accept the default name, and click Finish.
  12. 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:

  1. On the View menu, click Data Source.
  2. 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:

    Selecting a secondary data source from the Data Source task pane in InfoPath
    Figure 1. Selecting a secondary data source from the Data Source task pane in InfoPath.
  3. 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:

    The structure of the secondary data source from the Data Source task pane in InfoPath
    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.

 
 Subscribe for updates via RSS or Email

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services