Sunday, April 6, 2014

InfoPath 2013 Web Browser- Creating Cascading Dropdown Fields with no Code

How many times you require functionality where in based on the selection of parent drop down generates the values to the child drop down.
Examples, selection of Continent fills the Countries drop down.
We can achieve this functionality in INFOPATH Web forms without writing a single line of code.
Before you read on, I must tell you that this approach only works if you have the Enterprise version of SharePoint 2013 or the forms server. You will also need to have InfoPath 2013 Designer installed on your client machine.
Below Example shows 2 dropdowns, the first dropdown contains the Continents and the second dropdown contains the countries of the selected continents.
For the below demo, I have created 2 custom lists in SharePoint.
  • Custom List 1
    • Name: Continent
    • Column: Title (Type Single Text, which comes Out of Box with the custom list)
    • Custom List 2
      • Name: Country
      • Column: Title (Type Single Text, which comes Out of Box with the custom list)
      • Column: Continent(Type: Lookup, Get information from:  Continent, Column: Title)
Step1:
Add 2 dropdowns to the form, Let´s name the dropdown´s as Continent and Country, Should look like the below screenshot.
Image
Step2:   Now create 2 data Connections for both the dropdowns.
Creating Receive Data Connection for Continent:  Click on Data Connection
Image
Click on Add
Image
Select create a new Connection
  • Receive Data and click Next
Image
Select Source of your Data:
  • Select SharePoint Library or List as mentioned in the below screenshot.
Image
Provide URL of the Continent Lists
Image
Select the Continent List
Image
Select Title, Followed by Next, Next and Finish.
Image
Create a similar Receive Data Connection for County, the only difference is instead of selecting only Title, Select Title and Continent Column as well.
Image
Step3:
Assigning above created data connections to the dropdowns
Right click on the Continent dropdown and select the Drop-Down List Box Properties…
Image
Set the properties as shown in the below screenshot.
Image
Similarly Set the properties of the Country Dropdown as shown in the below screenshot.
Image
Now we need to make few adjustments to get the filter of the data when a continent is selected.
In the dropdown properties of the Country, select Image  of the entries section .

Image).
Select Filter Data
Image
Click Add
Image
And Select Continent Is Equal to Select a field or group and select the continent from Main
Image
Click on OK. Close all the popups by clicking ok on all popups.
Give full trust to the form and click F5 to see the demo
You will observer you have a cascading dropdown functionality in the INFOPATH forms without writing a single line of code.
Example
Image      Image
There is one tiny issue! The country drop down does not clear itself. Therefore if you pick another continent, the old country will stay the same as the one you had picked in the earlier pick of the city.
Step 4:
Select the Continent dropdown and select the Manage Rule Image
Image   Image         Click on New and select Action
Select the Set the Field Value as shown in the below screenshot.
Image
Set a field’s value, and then pick Country for the field. Leave the Value blank.
Image
Click on Ok.
Hit OK , and you are done!

No comments: