<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://k2underground.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tom's Random Thoughts</title><link>http://k2underground.com/blogs/tmil/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61120.2)</generator><item><title>Cascading Drop Downs with InfoPath Forms Server and SmartObjects</title><link>http://k2underground.com/blogs/tmil/archive/2007/09/06/cascading-drop-downs-with-infopath-forms-server-and-smartobjects.aspx</link><pubDate>Thu, 06 Sep 2007 22:39:00 GMT</pubDate><guid isPermaLink="false">1c9bda6b-c6e6-4e79-8d32-b70ad0011ef7:18470</guid><dc:creator>tmil</dc:creator><slash:comments>2</slash:comments><comments>http://k2underground.com/blogs/tmil/comments/18470.aspx</comments><wfw:commentRss>http://k2underground.com/blogs/tmil/commentrss.aspx?PostID=18470</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT face=Calibri size=3&gt;One of the features that I use frequently with InfoPath is the ability to do filters on a data source.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This allows me to create multiple dropdown box controls that drive the content of each successive drop down box.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;For example, I create two dropdown boxes that are called “State” and “City”.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Selecting the state in the first drop down box returns a filtered list of cities within that state to the second dropdown box.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This is a simple but powerful feature that is used quite frequently when developing InfoPath forms.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Unfortunately, filters are not supported in browser based forms.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;To work around this, a developer would typically create a web service that returns the list of cities based on the selected value of the “State” dropdown box.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I personally feel that if I’m going to need to write code to do this, why am I even using InfoPath at this point?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT face=Calibri size=3&gt;SmartObjects can be used to achieve this functionality without writing any code.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The following example uses two smart objects called Cities and States.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The InfoPath form will contain two dropdown boxes.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Selecting the state in the first dropdown box will populate the second box with the appropriate list of cities.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Create a new InfoPath form and save it locally.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Enable the check box to only allow browser-compatible features.&lt;IMG src="http://k2underground.com/photos/tmil/images/18463/original.aspx"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Navigate to the location where you saved the form template (.xsn).&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Right click on the file and choose “Integrate with SmartObject”.&lt;/FONT&gt;&lt;IMG src="http://k2underground.com/photos/tmil/images/18465/original.aspx"&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;3.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Add the GetList method for both the Cities Object and the States Object.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Please refer to the BlackPearl documentation for more information.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Calibri size=3&gt;&lt;IMG src="http://k2underground.com/photos/tmil/images/18467/original.aspx"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;4.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Click Tools &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY:Wingdings;mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;&lt;SPAN style="mso-char-type:symbol;mso-symbol-font-family:Wingdings;"&gt;è&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt; Form options and add a rule to run the States_GetList query when the form opens.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This will be used to retrieve a list of states to populate the first dropdown box.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun:yes;"&gt;&lt;IMG src="http://k2underground.com/photos/tmil/images/18468/original.aspx"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpMiddle style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;5.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Open the form in design mode and create two dropdown boxes; one for “City” and one for “State”.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l0 level1 lfo1;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;6.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Edit the properties of the “State”.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Change the Data Source to use the States_GetList method.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Drill into the Schema until the ReturnProperties node is visible.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I have set the value to be the StateID field, which is a unique field in my SmartObject.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The display name in this example is set to be the StateName field.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;Do the same thing for the “Cities” dropdown box.&lt;/FONT&gt;&lt;FONT face=Calibri size=3&gt;&lt;IMG src="http://k2underground.com/photos/tmil/images/18469/original.aspx"&gt;&lt;BR style="mso-special-character:line-break;"&gt;&lt;BR style="mso-special-character:line-break;"&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Everything to this point has been configured using standard InfoPath features with a bit of exposure to smart objects.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This is the part where we can use the SmartObject’s GetList method to return only the data that we want from the second object.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpFirst style="MARGIN:0in 0in 0pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l1 level1 lfo2;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;1.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;Open the “State” dropdown box properties and create a rule that set’s the value of the State input parameters of the Cities_GetList secondary datasource equal to the “State” dropdown box.&lt;BR&gt;&lt;/FONT&gt;&lt;IMG src="http://k2underground.com/photos/tmil/images/18464/original.aspx"&gt;&lt;A href="http://k2underground.com/photos/tmil/images/18464/original.asp"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l1 level1 lfo2;"&gt;&lt;SPAN style="mso-bidi-font-family:Calibri;mso-bidi-theme-font:minor-latin;"&gt;&lt;SPAN style="mso-list:Ignore;"&gt;&lt;FONT face=Calibri size=3&gt;2.&lt;/FONT&gt;&lt;SPAN style="FONT:7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;The second part of this rule will be to run the Cities_GetList method AFTER the value has been set on the input parameter.&lt;/FONT&gt;&lt;FONT face=Calibri size=3&gt;&lt;IMG style="WIDTH:422px;HEIGHT:321px;" height=321 src="http://k2underground.com/photos/tmil/images/18466/original.aspx" width=422&gt;&lt;BR style="mso-special-character:line-break;"&gt;&lt;/FONT&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoListParagraphCxSpLast style="MARGIN:0in 0in 10pt 0.5in;TEXT-INDENT:-0.25in;mso-list:l1 level1 lfo2;"&gt;&lt;FONT face=Calibri size=3&gt;&lt;A class="" title="Cascading Drop Down Video" href="http://k2underground.com/files/folders/18455/download.aspx"&gt;Click here for video&lt;/A&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P class=MsoNormal style="MARGIN:0in 0in 10pt;"&gt;&lt;FONT face=Calibri size=3&gt;You have now setup a group of cascading list boxes.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;This scenario is used repeatedly throughout form design to help guide a user through their choices and to ensure that they are only entering data that is relevant to the form.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I personally feel this is easier than setting up filters using InfoPath.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;The concepts here can easily be applied to more complex scenarios.&lt;SPAN style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/SPAN&gt;I hope this has been helpful.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://k2underground.com/aggbug.aspx?PostID=18470" width="1" height="1"&gt;</description><category domain="http://k2underground.com/blogs/tmil/archive/tags/InfoPath/default.aspx">InfoPath</category><category domain="http://k2underground.com/blogs/tmil/archive/tags/SmartObjects/default.aspx">SmartObjects</category><category domain="http://k2underground.com/blogs/tmil/archive/tags/Tips/default.aspx">Tips</category></item></channel></rss>