Receiving Data from SharePoint Lists and Business Connectivity Services

  • 10/15/2011

Adding a SharePoint List Data Connection

In the following exercise, you will add a control on an existing form so that the form can receive information from a SharePoint list.

In the scenario behind this exercise, you have had a request to add another field of information to the Flight Delay form to capture the name of the flight’s captain. One effective way to handle this requirement might be to add a SharePoint receive data connection because you already have a list of pilots’ names in SharePoint.

  1. Publish the Flight Delay form to a form library in SharePoint (if it is not already).

  2. Create a new SharePoint custom list in the same site. Call the list Pilot Names.

    httpatomoreillycomsourcemspimages1713872.png
  3. In the list, create one text column named Pilot Name.

  4. On the ribbon, on the List tab, click the List Settings button. Set the Require that this column contains information option of the Title column to No.

  5. Enter the following seven pilot names in your list:

    httpatomoreillycomsourcemspimages1713878.png
  6. Switch back to the Flight Delay form in InfoPath Designer. In the table on the top part of the form, right-click in the area below the Reason for Delay field.

    httpatomoreillycomsourcemspimages1713880.png
  7. In the label area, add the text Pilot Name, and then insert a Drop-Down List Box control. In the control’s properties, rename it PilotName.

  8. httpatomoreillycomsourcemspimages1713884.png On the ribbon, on the Data tab, click the From SharePoint List button to create a receive data connection on your form.

    The Data Connection Wizard opens.

  9. Provide the required information in the wizard to add the Pilot Names list you added in step 2. On the third page of the wizard, select the check box to add the Pilot Name field.

    httpatomoreillycomsourcemspimages1713886.png
  10. For the remainder of the wizard pages, accept the defaults, and then click Finish.

    Now you need to connect the SharePoint list receive to the Drop-Down List Box control.

  11. In the properties for the Pilot Name Drop-Down List Box control, select Get choices from an external data source and ensure that Pilot Names is selected, as shown in the following screenshot.

    httpatomoreillycomsourcemspimages1713888.png
  12. Click OK, and then press F5 to preview the form.

    You should now have the information from the SharePoint list available in your Pilot Name field.

  13. httpatomoreillycomsourcemspimages1713892.png Use the Quick Publish button to update the form library with your new and improved form.

    Now, anytime a new pilot name is added in the SharePoint list, your form will automatically display the name in the Drop-Down List Box control.