InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list - InfoPath Dev
in

InfoPath Dev

InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

Last post 01-21-2011 11:36 AM by ShinerDog. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-20-2011 02:49 PM

    InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    I am using InfoPath 2007.  The form will be used as a web based form in SharePoint 2007.  Here is my scenario: I have a repeating table with a dropdown menu. The dropdown menu is being autopopulated when the form is opened.  The first row of the repeating table works fine but any rows after that and the dropdown menu doesn't contain the autopopulated data.  I am not trying to do any cascading dropdown menus here...I just want the same data to appear in the dropdown.

    I am populating the dropdown menu by using code-behind and calling a SQL Stored Proc.  I am putting the data from the stored proc into a repeating group with fields (see code below).  I then create a dropdown field and use the "Look Up values in the form's data source" option.  I set the Entries field to "/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup"  and the value to "/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup/my:GLAccountRepeatingID" and the Display Name to "/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup/my:GLAccountRepeating". 

    All of this works for the first row of my repeating table; however, when any new rows are added to the repeating table, the dropdown menu is empty.  How can I get the dropdown to populate every time a user adds a new row to the repeating table?

    Thank you!

    Jennifer

     

    -----------------------

    XPathNavigator xpnRootNodeGL = MainDataSource.CreateNavigator().SelectSingleNode("/my:ExpenseReport", NamespaceManager);

    XPathNavigator xpnDataGroupGL = MainDataSource.CreateNavigator().SelectSingleNode("/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup", NamespaceManager);XPathNavigator xpnTemplateGL = xpnDataGroupGL.Clone();

     

    foreach (DataRow dRow in DS3.Tables[0].Rows)

    {

    XPathNavigator xpnNewDataGL = xpnTemplateGL.Clone();

    xpnNewDataGL.SelectSingleNode("/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup/my:GLAccountRepeatingID", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString());xpnNewDataGL.SelectSingleNode("/my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup/my:GLAccountRepeating", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString() + "|" + dRow["epicor_account_description"].ToString());

    xpnDataGroupGL.InsertAfter(xpnNewDataGL);

    }

    //delete extra item

    xpnDataGroupGL.DeleteSelf();

    DA3 =
    null;

    MyConnection.Close();

     

  • 01-20-2011 05:43 PM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    Clone() doesn't create a copy of the node.  You need to use InsertAfter() first, then select the newly-created node.  Also, you need to be using relative XPaths, not absolute ones.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-21-2011 06:24 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    Thank you for your quick response.  Can you give me a bit more detail on what you mean with the placement of InserAfter()?  Working with this is new to me so I am not completely following what I need to change.

    Thank you again!
    Jennifer

  • 01-21-2011 07:56 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    I've been looking at this more and I really just don't understand. Every example I see is using clone().  When I move the InsertAfter, I get an error.  Can you please send a code sample?

    Thank you again!

    Jennifer

  • 01-21-2011 08:11 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    Could you show me one of these examples that use Clone()?

    Even with the operations in the right order, making copies of nodes to fill in a repeating table is not a very good approach.  qRules' Insert command uses a much more robust approach, and I suggest checking that out.

    The below should work:

    foreach (DataRow dRow in DS3.Tables[0].Rows)

    {

       xpnDataGroupGL.InsertAfter(xpnTemplateGL);

       XPathNavigator xpnNewDataGL = xpnRootNodeGL.SelectSingleNode("my:ExpenseDetails/my:GLAccountsGroup[last()]", NamespaceManager);

       xpnNewDataGL.SelectSingleNode("my:GLAccountRepeatingID", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString());

       xpnNewDataGL.SelectSingleNode("my:GLAccountRepeating", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString() + "|" + dRow["epicor_account_description"].ToString());

       xpnDataGroupGL = xpnNewDataGL;

    }

    xpnTemplateGL.DeleteSelf();

     

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-21-2011 08:59 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    Hello! Thank you for the code sample.  Unfortunately, it is still not working for me. The dropdown in my repeating table populates for the first row but still does not populate for any new rows that are created in the table. Does this line still need to be clone()?

    XPathNavigator xpnTemplateGL = xpnDataGroupGL.Clone();

     

     

    See all code below...

    XPathNavigator xpnRootNodeGL = MainDataSource.CreateNavigator().SelectSingleNode("my:ExpenseReport", NamespaceManager);

    XPathNavigator xpnDataGroupGL = MainDataSource.CreateNavigator().SelectSingleNode("my:ExpenseDetails/my:GLAccountsGroup", NamespaceManager);

    XPathNavigator xpnTemplateGL = xpnDataGroupGL.Clone();

     

    foreach (DataRow dRow in DS3.Tables[0].Rows)

    {

    xpnDataGroupGL.InsertAfter(xpnDataGroupGL);

    XPathNavigator xpnNewDataGL = xpnRootNodeGL.SelectSingleNode("my:ExpenseDetails/my:GLAccountsGroup[last()]", NamespaceManager);

    xpnNewDataGL.SelectSingleNode("my:GLAccountRepeatingID", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString());

    xpnNewDataGL.SelectSingleNode("my:GLAccountRepeating", NamespaceManager).SetValue(dRow["epicor_account_code"].ToString() + "|" + dRow["epicor_account_description"].ToString());

    xpnDataGroupGL = xpnNewDataGL;

    }

    //delete extra item

    xpnTemplateGL.DeleteSelf();

     

    As far as the examples, I was searching on google using the keywords like: infopath 2007, populate a dropdown menu using code, repeating table, populate a repeating table using code.

    Thank you for your help!

    Jennifer

  • 01-21-2011 09:51 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    I have two screenshots that I wanted to upload to make sure we are talking about the same thing.  Can you post an image? I can't link to an image because I don't have a web location place to put it...I need to be able to upload it to the forum.   I want to make sure that we are both talking about the same issue..In my repeating table I have several columns.  One of the columns contains the dropdown menu.  This dropdown menu is populated by the code in this forum.  The dropdown menu has data in the first row of the repeating table but any new rows that a user creates in the repeating table, the dropdown menu is empty.  Only the first dropdown menu in the first row is populated.  How do I get the other dropdown menus in the repeating table to populate with data besides the first row?Sorry to restate what probably already makes sense to you.  Some of this InfoPath coding is completely new to me and I'm stumbling through.Thanks again for all the help...  Jennifer 
  • 01-21-2011 11:36 AM In reply to

    Re: InfoPath 2007 - Only first row of repeating table has auto-populated data in the dropdown list

    Hey! I figured out my problem! I had the fields in the infopath xml schema in the wrong location. I moved the GLAccountsGroup up from:

    /my:ExpenseReport/my:ExpenseDetails/my:GLAccountsGroup

    to:

     /my:ExpenseReport/my:GLAccountsGroup

    Once I moved them out of the repeating table that is the ExpenseDetails it started to work.  Basically I think I was resetting the GLAccountsGroup with each new row that was added.

     Thank you Jimmy for your help! You got me to thinking about the flow of events and the flow of code and then the light bulb went off!

    Thanks Again!

    Jennifer

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.