Repeating field current() - InfoPath Dev
in

InfoPath Dev

Repeating field current()

Last post 12-08-2011 11:28 AM by jaxkookie. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-07-2011 11:25 AM

    Repeating field current()

    I am struggle with an issue. I have several drop downs in  repeating section. the ddl1 is fed from code and filtered from a ddl outside the repeating section called Region. ddl1 in row 1 works perfectly. when I copy the repeating section or add a new seems that my ddls only have the previously selected values as options. I know in a rule you can set the value to current(), I am not sure how to set my filter (xpath) to current. so each new row will operate individually?

     

    any suggestions, please

    Kind regards,
    Larry
  • 12-07-2011 04:38 PM In reply to

    Re: Repeating field current()

    Hi -

    So I think you are saying that if you have additional instances of your repeating section, the filters on the drop down list are not behaving as anticipated - they filter for the first row's selection?

    If you look at your filter in the formula editor, and click Edit XPath, what's your XPath look like?

    Hilary Stoupa

  • 12-08-2011 06:05 AM In reply to

    Re: Repeating field current()

    Hi Hilary, Yes you are correct in your first statement. I do not have a formula on my field. I am populating the dropdown from a stored procedure with C#. On a load or change event I run some code to open the ds, query the data, close the connection and build the data table using this post as an example

    http://www.bizsupportonline.net/infopath2007/programmatically-fill-populate-drop-down-list-box-infopath-2007.htm

    Actually the dropdown is using a resource file that is a simple xml. the code behind does all the work. the problem with the post is it wasnt using this code in a repeating section, other wise it works perfectly.

     

    so now I am at an empass. this code populates my first ddl

      public void CmdtyGroup()
            {
                string DSName = "Group_AgreementLineItems"; // the XML resource file name
                string xpathReg = "/my:myFields/my:myHeader/my:Header/my:Region";
                string xpathRN = "/my:myFields/my:myLineItems/my:CmdtySect/my:Commodity/my:RegionName";
                          
                XPathNavigator Region = MainDataSource.CreateNavigator().SelectSingleNode(xpathReg, NamespaceManager);
                XPathNavigator RegionName = this.MainDataSource.CreateNavigator().SelectSingleNode(xpathRN, this.NamespaceManager);

                            try
                {
                    //Multiple Rows Expected
                    DataTable MyData = GetDataTable("EXEC Get_CPMSD_CommodityGroup '" + RegionName + "'", "Get_CPMSD_CommodityGroup");
                    if (MyData != null)
                    {
                        ClearItems(DSName);
                        AddItems(DSName, MyData.Rows, "CommodityGroup");
                    }
                }
                catch (Exception ex)
                {
                    string log = ex.Message;
                    throw new Exception(ex.Message);
                }
            }

     this code populate the second ddl where I an having the problems and uses the value from the previous selection

     public void CmdtySubGroup()
            {
                string DSName = "SubGroup_AgreementLineItems";
                string xpathCG = "/my:myFields/my:myLineItems/my:CmdtySect/my:Commodity/my:CmdtyGroup"; //"my:CmdtyGroup";  
               
                XPathNavigator Cmdty = this.MainDataSource.CreateNavigator().SelectSingleNode(xpathCG, this.NamespaceManager);
                                  try
                {
                    //Multiple Rows Expected
                    DataTable MyData = GetDataTable("EXEC Get_CPMSD_CommoditySubGroup '" + Cmdty + "'", "Get_CPMSD_CommoditySubGroup");
                    if (MyData != null)
                    {
                        ClearItems(DSName);
                        AddItems(DSName, MyData.Rows, "CommoditySubGroup");
                    }
                }
                catch (Exception ex)
                {
                    string log = ex.Message;
                    throw new Exception(ex.Message);
                }
            }

     

    do you need any more info?

    Kind regards,
    Larry
  • 12-08-2011 08:57 AM In reply to

    Re: Repeating field current()

    Got it.

    Okay, you are always going to be getting the first instance of CmdtyGroup in your code for the second drop down.

    I'd suggest you change your method and pass in the current row CmdtyGroup - add the changed event to that field, and pass e.NewValue to the CmdtySubGroup method. The you could just use that string in your stored procedure.

    A word of warning.

    If you change the values in the data source for the drop down based on the selection in the second row (for example) and the user wishes to change her selection in the first row - the only options she'll have available are those based on the CmdtyGroup from the second row (awkward phrasing, sorry!). So you'll need to do a little UI work to give the user a better experience - make her click something to change her selection so you can re-run your code to get back the correct options based on the selected CmdtyGroup for the row.

    Hilary Stoupa

  • 12-08-2011 11:28 AM In reply to

    Re: Repeating field current()

    Thanx H,

     

    You rock! as always!

    Kind regards,
    Larry
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.