how to navigate through a repeating section within a repeating section - InfoPath Dev
in

InfoPath Dev

how to navigate through a repeating section within a repeating section

Last post 06-12-2012 12:16 PM by Hazel. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-07-2012 04:47 AM

    • Hazel
    • Not Ranked
    • Joined on 06-05-2012
    • Posts 3

    how to navigate through a repeating section within a repeating section

    I am trying to send data from a submitted InfoPath form via email.  My form has a repeating section ('group3') within a repeating section ('group2').  Each email will contain all of the data in an instance of ‘group2’.  I am able to move all of the fields from 'group2' to my email, but I don’t know how to navigate through ‘group 3’.  Can someone help me? (I’m very new to this, have taken something that someone else has started and am trying to complete it.)

    My data looks something like this:

    -          myFields

    -          group2

    -          ComputerChangeInfo

    -          _AssetTag

    -          _CurrentComputer

    -          group3

    -          AccountingInfo

    -          _acct2

    -          _unit2

     

    Here is the code that I’m using to navigate through ‘group2’:

                Dim root As XPathNavigator = Me.MainDataSource.CreateNavigator()            Dim rows As XPathNodeIterator = root.Select("my:myFields/my:group2/my:ComputerChangeInfo", Me.NamespaceManager)            Dim tag As String            Dim currentcomputer As String             Dim count As Int32 = rows.Count()            Dim current As Int32            While current < count                rows.MoveNext()                current = rows.CurrentPosition()                tag = "*" & rows.Current.SelectSingleNode("my:_AssetTag", Me.NamespaceManager).Value & "*"                currentcomputer = "Current Computer:" & rows.Current.SelectSingleNode("my:_CurrentComputer", Me.NamespaceManager).Value & System.Environment.NewLine

                End While

     

  • 06-07-2012 10:11 AM In reply to

    Re: how to navigate through a repeating section within a repeating section

    Hi - so, ComputerChangeInfo and group3 are repeating? From your outline - it looks like they are siblings. Or is group3 inside of ComputerChangeInfo?

    If group3 is a repeating child of ComputerChangeInfo, you are already partway there. You could create another node iterator inside your While loop for ComputerChangeInfo nodes and loop again to get your group3 info - to would be rows.Current.Select('my:group3", NamespaceManager).

    If group3 is a sibling, at the end of your while loop, you could create another iterator for it, just like you did for ComputerChangeInfo.

    Hilary Stoupa

  • 06-11-2012 05:05 AM In reply to

    • Hazel
    • Not Ranked
    • Joined on 06-05-2012
    • Posts 3

    Re: how to navigate through a repeating section within a repeating section

    I am unable to attach a screen shot - sorry!

    ComputerChangeInfo & group3 are siblings...group2 is the parent. 

    _AssetTag & _CurrentComputer are siblings...ComputerChangeInfo is the parent.

    group3 is the parent of AccountingInfo.

    _acct2 & _unit2 are siblings...AccountingInfo is the parent.

     

     

  • 06-11-2012 08:08 AM In reply to

    Re: how to navigate through a repeating section within a repeating section

    Then you'd implement a similar loop for group3 that you have currently for ComputerChangeInfo. So you know for next time, under the Options tab in a reply, you can attach a file, including a picture. :-)

    Hilary Stoupa

  • 06-12-2012 12:16 PM In reply to

    • Hazel
    • Not Ranked
    • Joined on 06-05-2012
    • Posts 3

    Re: how to navigate through a repeating section within a repeating section

    I've attached a screen shot of my data structure. 

    As a test, I submitted a form that has 2 instances of 'ComputerChangeInformation'.  The 1st instance of 'ComputerChangeInformation' has 1 instance of 'AccountingInfo';  the 2nd has 2.

    My code navigates through the 2 instances of 'ComputerChangeInfo' correctly, but it navigates through all 3 instances of 'AccountingInfo' while still in the 1st instance of ComputerChangeInfo.  I'm sure there is an easy fix - I just don't know what it is.

                Dim root As XPathNavigator = Me.MainDataSource.CreateNavigator()            Dim user As XPathNavigator = root.SelectSingleNode("my:myFields/my:userID", Me.NamespaceManager)...             Dim rows As XPathNodeIterator = root.Select("my:myFields/my:group2/my:ComputerChangeInfo", Me.NamespaceManager)            Dim rows2 As XPathNodeIterator = root.Select("my:myFields/my:group2/my:ComputerChangeInfo/my:group3/my:AccountingInfo", Me.NamespaceManager)             Dim tag As String            Dim currentcomputer As String...             Dim entity2 As String            Dim acct2 As String...             Dim count As Int32            Dim current As Int32            Dim count2 As Int32            Dim current2 As Int32             current = rows.CurrentPosition()            count = rows.Count()            While current < count                rows.MoveNext()                current = rows.CurrentPosition()                tag = "*" & rows.Current.SelectSingleNode("my:_AssetTag", Me.NamespaceManager).Value & "*"                 currentcomputer = System.Environment.NewLine & "Current Computer:" & rows.Current.SelectSingleNode("my:_CurrentComputer", Me.NamespaceManager).Value & System.Environment.NewLine...                 current2 = rows2.CurrentPosition()                count2 = rows2.Count()                While current2 < count2                    rows2.MoveNext()                    current2 = rows2.CurrentPosition()                     entity2 = "Entity:" & rows2.Current.SelectSingleNode("my:_entity2", Me.NamespaceManager).Value & ";  "                    acct2 = "Account:" & rows2.Current.SelectSingleNode("my:_acct2", Me.NamespaceManager).Value & ";  "...                End While ...

                End While

     


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