What is Cascading drop downs? Well, Cascading drop downs are linked drop down controls where the content of the second drop down depends on the selection of the first one. E.g. When you Choose Country in the first drop down, the second drop down State is automatically filtered to the list of states actually in that county. Cascading drop downs are quite a common requirement and unfortunately, SharePoint doesn’t support it Out of the box.
In this article, I’m documenting the implementation of cascading drop down functionality in SharePoint list forms using InfoPath forms step by step (at least for my own reference! even a simple mistake takes hours to resolve).
In short: You create a new data source to retrieve “Region” and “Country” columns from the Countries list and then filter the countries drop down to show only items matching with the “Region” selected in “Regions” drop down.
InfoPath Cascading Dropdown List Setup:
Here is my List setup:
- Regions – List of Regions – Parent List for Countries list’s Region column.
- Countries -List of Countries with Region as lookup column from “Regions” list
- Projects List – List to capture project data, Where Region and Country columns are from above lists as lookup columns.
Step 1: Customize SharePoint List in InfoPath Designer
Open the Project SharePoint list in browser, Click on “Customized Form” button under List Tab. This opens your SharePoint list form in InfoPath Designer. Alternatively, You can open InfoPath Designer and Customize SharePoint List form. This establishes the data connections between SharePoint list and InfoPath.
BTW, To utilize InfoPath browser farms you need to have SharePoint Server Enterprise edition and “SharePoint Server Enterprise Site Collection features” feature activated at the site collection level.
Step 2: Create New Data Connection:
Add new data connection in InfoPath to retrieve Country & its respective Region.
Step 3: Change the Data Source of the “Country” Drop down and Apply Filter:
Once we created the data source for Country,
- Select the “Country” Drop Down in InfoPath form designer, Right Click and choose “Drop down List box Properties” to get the Control Properties window.
- In Data source dropdown, Select the new data source we created in Step 1 (In my case its: “Country”). Now, proceed to step.
Apply Filter to Country Dropdown:
The Next step is to filter country values in the Country drop-down based on the selected Region.
- In Entries section, click on the tree button. This brings Select Field or Group window.
- Select the d:SharePointListItem_RW node under “DataFields” and click on Filter Data button.
- In the Filter Data window, click on Add button
- In specify Filter Conditions,
Set Value and display Name Fields of Country Drop down:
Finally, in the Country drop down properties, Set the Value and Display name fields to ID and Title respectively by selecting it through the tree button. This is because the Country drop-down is a lookup field and it stores lookup ID value internally. If you leave it as d:Title you will get an error when you try to save the list item.
Step 4: Add a Rule to “Regions” Drop down to Clear Countries Drop down on Re-selection:
This is important, because You’ll have to clear the secondary cascading drop downs upon re-selection of primary drop down.
- Select the Region Drop down in InfoPath designer, From the ribbon click on Add Rule, Select This Field Changes, Set a Field’s value.
- Choose the field as “Country”, leave the Value as blank and click OK.
That’s it! Now, from InfoPath Designer, Save and Publish the form!