locked
Clearing a dropdown box when another dropdown changes RRS feed

  • Question

  • I have two repeating dropdowns. One called ChangeType and one called ChangeSubType. They are fed using a list as an external datasource.

    Selecting a ChangeType populate ChangeSubType with different choices which is good. But when someone selects a second ChangeType the ChangeSubType dropdown displays the choices from the first ChangeType plus the ones from the second. How do I get it to only show choices relevant to the currently selected ChangeType?

    Wednesday, August 24, 2011 12:21 AM

All replies

  • Hi Peter,

    You may perform the filtered cascading drop down list using code. Please add following code to clear the last selected value in ChangeSubType drop down list in selected value changed event of ChangeType.

    Root.SelectSingleNode(“//my:ChangeSubType”,NamespaceManager).SetValue(“”);

    Or please take a look at this blog to create cascaded drop down lists in InfoPath form.
    http://www.bizsupportonline.net/browserforms/filter-cascade-drop-down-infopath-sharepoint-browser-form-owssvr-dll.htm

    Thanks & Regards,
    Emir Liu
    TechNet Subscriber Support in forum
    If you have any feedback on our support, please contact
     
    tnmff@microsoft.com.

    Wednesday, August 24, 2011 9:37 AM
  • Hi Peter,

    What I do is add a rule to the ChangeType dropdown.  You will need to add three actions:

    Set a field's value:  Field = ChangeSubType; Value = (leave this blank)
    Set a field's value:  Set the query field in the ChangeSubType Secondary DataConnection that matches the ChangeType to the ChangeType value
    Query Using a data connection:  The ChangeSubType data connection

    • Marked as answer by Peter_Atherton Wednesday, August 24, 2011 2:34 PM
    • Unmarked as answer by Peter_Atherton Wednesday, August 24, 2011 2:55 PM
    Wednesday, August 24, 2011 12:50 PM
  • I think the problem might be that I'm using one data connection for both. I've just create a new data connection for ChangeType and I'll see if that works
    Wednesday, August 24, 2011 2:36 PM
  • Oops, thought it was working but it's not. I think it's the second action I'm still having problems with.
    Wednesday, August 24, 2011 2:56 PM
  • No problem -

    In the second action, choose set a field's value.  For the field to set go to the ChangeSubType Secondary Data Connection (from the dropdown on the top).  Expand Query Fields - select the ChangeType field (this may be a different name - but it's values should contain the ChangeType values)

    Then for the value, click "fx", then click "Insert field or group".  Select the ChangeType field from the main datasource in your form. 

    • Marked as answer by Emir Liu Monday, September 5, 2011 2:23 AM
    • Unmarked as answer by Peter_Atherton Wednesday, September 7, 2011 1:49 PM
    Wednesday, August 24, 2011 5:25 PM
  • I can't get this to work but I think it has to do with the way I've set this up. It works properly if I only have 1 ChangeType. If I change the ChangeType it does not keep the ChangeSubTypes from the one I picked before, but in my situation the ChangeType field is a repeating dropdown. For each change record there can be multiple Change Types. i.e. both Infrastructure items and Modeling Items have SubTypes.

    I've attached a graphic to show what I mean. I've followed your instructions and I still get the same result. The ChangeSubTypes from Infrastructure are still there even though I've picked Modeling as the second change type.

     

    Wednesday, September 7, 2011 2:08 PM
  • Not sure if this is still open?

    If you're using a repeating table, you need to set the filter to the current ChangeType row, using my:current - see

    http://www.infopathdev.com/blogs/greg/archive/2005/07/14/Create-a-Repeating-Cascading-List-from-a-Hierarchical-Data-Source.aspx

    Monday, March 19, 2012 3:18 PM
  • Thanks, I never did come to end of job on this I'll look into your suggestion.

    Friday, March 23, 2012 2:36 PM