Duplicates Across Nested Repeating Sections - InfoPath Dev
in

InfoPath Dev

Duplicates Across Nested Repeating Sections

Last post 07-20-2006 08:03 AM by blakeman. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-10-2006 02:43 PM

    Duplicates Across Nested Repeating Sections

    This is my first post here. Love the info I've picked up so far.

    I've been struggling with trying to put together an expression in InfoPath and have almost pulled my hair out. My gut says this is something I can probably accomplish using an xpath expression, but just can't seem to put it together. Here's the situation: I have multiple nested repeating sections in my form. At just about each level I need to show a list of a particular field in a child repeating section without showing any duplicates. The duplicates are ok in the field, but I don't want them in the expression, mostly in the interest of space and readibility. One catch is that each parent level is also a repeating section as well. Using the eval function I've been able to prevent duplicates in each section, but can't prevent those duplicates from appearing in the parent sections. This probably doesn't make any sense, but the bottom line is how can I combine (concat?) the values from children repeating sections without duplicates, plus pass those values up to the parent and show an expression that doesn't have duplicates either?. Sort of a roll up of the child repeating sections at each parent level. I am a self taught geek, but certainly not a trained programmer. I've been amazed at what I can do with InfoPath, but this one escapes me. I've included an example below. In asterisks, I've put the result of the expression I'm looking for. Any help is appreciated. Thanks.

    Here's the eval expression I messed around with:
    eval(eval(RepeatingSection2, 'concat(Field1[not(. = preceding::RepeatingSection2/field1)], " ")'), "..")


    <Section1> ***Expression for field1: RED, GREEN, BLUE, YELLOW***
    <RepeatingSection1>
    <Section2> ***Expression for field1: RED, GREEN
    <RepeatingSection2>
    <field1>RED</field1>
    </RepeatingSection2>
    <RepeatingSection2>
    <field1>RED</field1>
    </RepeatingSection2>
    <RepeatingSection2>
    <field1>GREEN</field1>
    </RepeatingSection2>
    </Section2>
    </RepeatingSection1>
    <RepeatingSection1>
    <Section2> ***Expression for field1: GREEN, RED, BLUE***
    <RepeatingSection2>
    <field1>GREEN</field1>
    </RepeatingSection2>
    <RepeatingSection2>
    <field1>RED</field1>
    </RepeatingSection2>
    <RepeatingSection2>
    <field1>BLUE</field1>
    </RepeatingSection2>
    <RepeatingSection2>
    <field1>RED</field1>
    </RepeatingSection2>
    </Section2>
    <RepeatingSection1>
    <Section2> ***Expression for field1: YELLOW***
    <RepeatingSection2>
    <field1>YELLOW</field1>
    </RepeatingSection2>
    </Section2>
    </RepeatingSection1>
    </Section1>
  • 07-10-2006 07:05 PM In reply to

    Re: Duplicates Across Nested Repeating Sections

    Hey Brian, glad you've gotten so much out of the forums and I hope you continue to contribute!

    This is an interesting problem. XPath can be incredibly elegant at times and I think this is one of those times. I worked up a sample form to accomplish what you wanted, and if you'd like I can e-mail it to you. Here are the XPaths I used. I've hightlighted the tricky parts in red and included the schema of my sample form below.

    Section1:
    xdMath:Eval(xdMath:Eval(//my:group4, 'concat(my:field1[not(. = preceding::my:field1)], " ")'), "..")

    Section2:
    xdMath:Eval(xdMath:Eval(.//my:group4, 'concat(my:field1[not(. = ../preceding-sibling::my:group4/my:field1)], " ")'), "..")

    group1
    --Expression1 (this is not actually in the XML, just showing where I put them in the XSL)
    --group2 (repeating)
    ----group3
    ----Expression2
    ------group4 (repeating)
    --------field1

    I hope this helps and let me know if you want that sample form!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-11-2006 09:41 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    Thanks Matt! I think we're heading in the right direction, but I may not have explained myself very well (and my initial example doesn't help). I am dealing with two different fields and not one. I have included a copy of my schema below (with the names changed to protect the guilty), and where I need the expressions and the results I need. I hope this makes it clearer...and that there is a way to do this.

    If you're wondering why all the nesting, I need to maintain the traceability across business requirements and business rules for my company's form. We've done this in Word before, but InfoPath is by far a better solution. The catch is that the detail regarding impacted systems (indicated by Fields 1 and 2) must to be shown at the top of each section. This allow me to collapse those sections (Groups 4 and 9)and still see the impacted systems. However, because the systems (Contained in Groups 7 and 12) could be duplicated across requirements (group 4) and rules (group 9), and ulitmately roll up to business components (Group2), I need to show all the impacted systems across all the requirements and rules. My wish is to do this without showing any duplicates. Maybe this helps to better explain what I'm trying to accomplish. Thanks again! And sorry this is to dang long!


    <my:Group1>
    --<my:Group2>(Repeating) Exp1= concat ALL Field1 and Field2 w/no dup, BUT for children only. I don't want to see Field1 or Field2 from a sibling of Group2.
    ----<my:Group3>
    ------<my:Group4>(Repeating) Exp2= concat Field1 and Field 2 w/no dup, BUT for children only. I don't want to see Field1 or Field2 from a sibling of Group4
    --------<my:Group5>
    ----------<my:Group6>
    ------------<my:Group7> (Repeating)
    --------------<my:Field1>
    ------------</my:Group7>
    ----------</my:Group6>
    --------</my:Group5>
    --------<my:Group8>
    ----------<my:Group9> (Repeating)Exp3= concat Field2
    ------------<my:Group10>
    --------------<my:Group11>
    ----------------<my:Group12> (Repeating)
    ------------------<my:Field2>
    ----------------</my:Group12>
    --------------</my:Group11>
    ------------</my:Group10>
    ----------</my:Group9>
    --------</my:Group8>
    ------</my:Group4>
    ----</my:Group3>
    --</my:Group2>
    </my:Group1>


    Here's another example:
    <my:Group1>
    --<my:Group2>(Repeating) Exp1= RED, ORANGE, GREEN, YELLOW, BLUE, INDIGO
    ----<my:Group3>
    ------<my:Group4>(Repeating) Exp2= RED, ORANGE, GREEN, YELLOW
    --------<my:Group5>
    ----------<my:Group6>
    ------------<my:Group7> (Repeating)
    --------------<my:RED>
    ------------</my:Group7>
    ------------<my:Group7> (Repeating)
    --------------<my:ORANGE>
    ------------</my:Group7>
    ------------<my:Group7> (Repeating)
    --------------<my:GREEN>
    ------------</my:Group7>
    ----------</my:Group6>
    --------</my:Group5>
    --------<my:Group8>
    ----------<my:Group9> (Repeating)Exp3= RED, YELLOW
    ------------<my:Group10>
    --------------<my:Group11>
    ----------------<my:Group12> (Repeating)
    ------------------<my:RED>
    ----------------</my:Group12>
    ----------------<my:Group12> (Repeating)
    ------------------<my:YELLOW>
    ----------------</my:Group12>
    --------------</my:Group11>
    ------------</my:Group10>
    ----------</my:Group9>
    --------</my:Group8>
    ------</my:Group4>
    ----</my:Group3>
    --</my:Group2>
    ------<my:Group4>(Repeating) Exp2= GREEN, INDIGO, BLUE
    --------<my:Group5>
    ----------<my:Group6>
    ------------<my:Group7> (Repeating)
    --------------<my:GREEN>
    ------------</my:Group7>
    ------------<my:Group7> (Repeating)
    --------------<my:INDIGO>
    ------------</my:Group7>
    ----------</my:Group6>
    --------</my:Group5>
    --------<my:Group8>
    ----------<my:Group9> (Repeating)Exp3= BLUE, INDIGO
    ------------<my:Group10>
    --------------<my:Group11>
    ----------------<my:Group12> (Repeating)
    ------------------<my:BLUE>
    ----------------</my:Group12>
    ----------------<my:Group12> (Repeating)
    ------------------<my:INDIGO>
    ----------------</my:Group12>
    --------------</my:Group11>
    ------------</my:Group10>
    ----------</my:Group9>
    --------</my:Group8>
    ------</my:Group4>
    ----</my:Group3>
    --</my:Group2>
    </my:Group1>
    <my:Group1>
    --<my:Group2>(Repeating) Exp1= FORD, VW, CHEVY, HONDA, TOYOTA
    ----<my:Group3>
    ------<my:Group4>(Repeating) Exp2= FORD, VW, CHEVY
    --------<my:Group5>
    ----------<my:Group6>
    ------------<my:Group7> (Repeating)
    --------------<my:FORD>
    ------------</my:Group7>
    ------------<my:Group7> (Repeating)
    --------------<my:VW>
    ------------</my:Group7>
    ----------</my:Group6>
    --------</my:Group5>
    --------<my:Group8>
    ----------<my:Group9> (Repeating)Exp3= CHEVY, FORD
    ------------<my:Group10>
    --------------<my:Group11>
    ----------------<my:Group12> (Repeating)
    ------------------<my:CHEVY
    ----------------</my:Group12>
    ----------------<my:Group12> (Repeating)
    ------------------<my:FORD>
    ----------------</my:Group12>
    --------------</my:Group11>
    ------------</my:Group10>
    ----------</my:Group9>
    --------</my:Group8>
    ------</my:Group4>
    ----</my:Group3>
    --</my:Group2>
    ------<my:Group4>(Repeating) Exp2= VW, TOYOTA, FORD, HONDA
    --------<my:Group5>
    ----------<my:Group6>
    ------------<my:Group7> (Repeating)
    --------------<my:VW>
    ------------</my:Group7>
    ------------<my:Group7> (Repeating)
    --------------<my:TOYOTA>
    ------------</my:Group7>
    ----------</my:Group6>
    --------</my:Group5>
    --------<my:Group8>
    ----------<my:Group9> (Repeating)Exp3= FORD, HONDA
    ------------<my:Group10>
    --------------<my:Group11>
    ----------------<my:Group12> (Repeating)
    ------------------<my:FORD>
    ----------------</my:Group12>
    ----------------<my:Group12> (Repeating)
    ------------------<my:HONDA>
    ----------------</my:Group12>
    --------------</my:Group11>
    ------------</my:Group10>
    ----------</my:Group9>
    --------</my:Group8>
    ------</my:Group4>
    ----</my:Group3>
    --</my:Group2>
    </my:Group1>



  • 07-11-2006 10:14 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    Now I'm really confused. When you say you have fields like <my:FORD> and <my:HONDA> are you saying that you have an undefined set of fields that the user can choose from or are you talking about VALUES from a few different fields? For the latter, take a look at this. I didn't test, but I'm thinking it will work.

    What do you think? This is for your first solution, BTW.


    concat(
    xdMath:Eval(xdMath:Eval(.//my:group7, 'concat(my:field1[not(. = ../preceding-sibling::my:group7/my:field1) and not(. = ../../../../my:group8/my:group9/my:group10//my:group12/my:field2)], " ")'), "..")
    , " " ,
    xdMath:Eval(xdMath:Eval(.//my:group12, 'concat(my:field2[not(. = ../preceding-sibling::my:group12/my:field2) and not(. = ../../../../../../my:group5/my:group6//my:group7/my:field2)], " ")'), "..")
    )



    If you have an arbitrarily large set of possible XML elements, you might be able to use the child keyword or something, but I'm assuming that's not what you're trying to do.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-11-2006 11:48 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    Sorry, yes, those are values of the fields. When you say "...first solution," do you mean what I called "Exp1?" I'm guessing yes, so I went ahead and tried the expression you gave. I'm still seeing duplicates though. It works until I add another instance of group4 or group9.

    Another thing I noticed in your expression was on the first "inner" concat: 'concat(my:field1[not(. = ../preceding-sibling::my:group7/my:field1) and not(. = ../../../../my:group8/my:group9/my:group10//my:group12/my:field2)], " ") I noticed you have my:group10//my:group12 Is that right? I was thinking it would go my:group11//my:group12, but you're the expert, so I'll defer to you. Also, on the second "inner" concat I noticed you reference field2 after my:group7. Is that correct too? All of this seems nutty to me. I didn't know jack about XPath a couple of weeks ago. Now I feel like I've had a crash course. However, after seeing your examples I think I just don't get it yet. Again, I really appreciate your help. You have know idea how many hours I've tried to get this to work on my own. I figured it was time to ask the experts.
  • 07-11-2006 11:55 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    The my:group10//my:group12 was intentional, the other was a mistake. This is getting really complicated. If you can make a sample form of exactly the schema that you are trying to display, with expression boxes and the XPaths you are trying to use and send it to me, it will be much easier to think about.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-12-2006 11:40 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    Matt, I went ahead and forwarded my form to you. Thought I'd mention it here just in case you hadn't check email. Thanks.
  • 07-20-2006 08:03 AM In reply to

    Re: Duplicates Across Nested Repeating Sections

    For anyone following this thread (unlikely), I'll be playing with the sample form from Matt and trying to work it out. I'll post my results here.
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.