Adding a drop-down menu to InfoPath using SharePoint list data

In this recipe, we will add a drop-down menu that uses data provided by the custom list we created previously in the Creating a SharePoint list to provide drop-down menu data to InfoPath recipe.

Getting ready

For this recipe, we should have a SharePoint list created to retrieve data from.

How to do it...

Follow these steps to create a drop-down menu that uses SharePoint list data:

  1. Create a new form template or open an existing one in Microsoft InfoPath Designer 2013.
  2. Select From SharePoint List from the DATA tab present in the ribbon as shown in the following screenshot:
    How to do it...
  3. Provide the URL to the SharePoint site that contains the list and click on Next.
  4. Select the list and click on Next.
    How to do it...
  5. Select the field you want to display in the drop-down menu. In the case of our Categories list, select Title as shown in the following screenshot:
    How to do it...
  6. In the Sort By field, select Title to sort the fields according to their title.
  7. Click on Next, then again on Next, and then click on Finish.
  8. Add a Combo Box control to the form template and provide the control an appropriate name, such as category.
    How to do it...
  9. Select the control.
  10. Navigate to CONTROL TOOLS | PROPERTIES and select Edit Choices as shown in the following screenshot:
    How to do it...
  11. Select Get choices from an external data source as shown in the following screenshot:
    How to do it...
  12. Set Categories for Data source, ID for Value, and Title for the Display name and then click on OK.
  13. From the HOME tab, select Preview to observe the newly created drop-down menu. When testing your InfoPath form, you can use the Preview function. This allows you to test your form without publishing it to SharePoint. Observe the drop-down list for the Category field as shown in the following screenshot:
    How to do it...

How it works...

When creating a connection to SharePoint list data, InfoPath uses the SharePoint web services to connect to, and retrieve information about, the SharePoint list. SharePoint uses this connection information to retrieve the list data when rendering the form in the web browser. List data can be retrieved when the form is opened or can be retrieved when triggered by a user action.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.77.158