Preceding Sibling in Repeating Table Action Rules - InfoPath Dev
in

InfoPath Dev

Preceding Sibling in Repeating Table Action Rules

Last post 04-20-2016 08:10 AM by Hilary Stoupa. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-18-2016 11:59 AM

    Preceding Sibling in Repeating Table Action Rules

    Hi, I'm struggling with the preceding sibling expression and wasn't able to find anything previously posted that helped in this situation. I'm using IP 2010, QRules 6.1 (maybe there is something I can do here instead of preceding sibling?). It's a browser form. I have 3 fields in a repeating table: Customer, Year, Concatenated Customer-Year (named Add_Year_Cust). I need to see if there are any duplicate customer/year combinations entered. I have been successful in turning the Year field "red" when a duplicate is found with: preceding-sibling::my:Item[my:Add_Year_Cust = current()/my:Add_Year_Cust] (this turns the 2nd occurrence of Year red (I'm not concerned with turning both, so I didn't try to work in a following sibling or anything) Now, I need to disable the Submit button (I created, not an IP Submit) if a match is found. I wasn't able to figure out a formula on the button itself, and thought the best thing is to create a "test" field in the repeating table. I added 2 Action Rules on the Year field (I also tried putting these rules on all the other fields, but it didn't help). Action Rule 1) I put the same expression for my condition and then setting the test field to "Match". preceding-sibling::my:Item[my:Add_Year_Cust = current()/my:Add_Year_Cust] Action Rule 2) I put the same expression but no equal to and setting the test field to "No". preceding-sibling::my:Item[my:Add_Year_Cust != current()/my:Add_Year_Cust] The idea was then I would have a formatting rule on my button to look for any occurrence of "Match" and then disable the button. However, neither condition is ever being met... the rules aren't changing the value of my test field either way (it remains blank which is my default). I would've thought at least the first rule would've worked since it's the same as the one on the conditional rule (which works). I wasn't sure about the second one. Attaching an image... Any help would be really appreciated :) Thanks, Gwen
  • 04-18-2016 12:04 PM In reply to

    Re: Preceding Sibling in Repeating Table Action Rules

    Sorry, I originally added spacing to make this more readable, but when I posted, it lumped everything together.
  • 04-18-2016 02:35 PM In reply to

    Re: Preceding Sibling in Repeating Table Action Rules

    So - you just need to disable the button if you have two items that match? See if the attached sample helps you at all - save locally, right click and select design, then preview so you can try it. PS > as to the spacing issue, I'm finding that IE works best for the forum. What browser are you using? I'm using Edge right now and it just makes a mess. :)
    Hilary Stoupa

  • 04-19-2016 02:12 PM In reply to

    Re: Preceding Sibling in Repeating Table Action Rules

    Hi Hilary, thanks for this. Your sample works great, but for some reason my form isn't working when I put in the code (with my fields of course :)).  It's bizarre, I even copied my xpath to make sure I had the field name/path correct. I can't figure out what I'm missing.  I even switched the field that I'm testing to another field that is a simple text field.  The field I need to work is a concatenated field (2 text fields put together) and I thought maybe this was the issue (with it having a default value).  I don't have a default value on my repeating table (so no rows show on entry), but I removed yours and yours still worked fine.

    Can I email you my form? I tried to attach a simplified version of it (I removed a lot of stuff/data connections that you don't need, so it's not so jumbled), but the file size is too big.  Just curious to see if you can see what I'm missing? 

      

    I was using Chrome as my browser on the original post. I'll stick with IE from now on :) 

     Thanks! Gwen

  • 04-19-2016 03:24 PM In reply to

    Re: Preceding Sibling in Repeating Table Action Rules

    I just emailed you via your forum email address, so you can reply with the template. It may be tomorrow before I can take a look. :)
    Hilary Stoupa

  • 04-20-2016 08:10 AM In reply to

    Re: Preceding Sibling in Repeating Table Action Rules

     Okay - just to wrap this post up, after looking at the template, the issue had to do with the location of the submit button. The XPath was invalid because it wasn't relative to the actual button location. Here's how to use InfoPath to test your expression -

    1. Add another condition on the button
    2. Just leave the first & second dropdowns to their default values, we don't care, we aren't going to keep the new condition
    3. In the third dropdown, select "Use a formula" to open the formula editor
    4. Paste in the expression you are attempting to use - and click the Verify Formula button
    5. If you don't get any errors - hooray! Something else must be wrong if things aren't working as anticipated (if you are me, you have forgotten to use not instead of != or some other silliness)
    6. If you do get an error, you can work through what the issue is - sometimes it helps if you select the group or field you are using in your expression and click Edit XPath so you can see the relative path 
    Hilary Stoupa

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