Error flag to appear on all controls in repeating section - InfoPath Dev
in

InfoPath Dev

Error flag to appear on all controls in repeating section

Last post 09-21-2009 07:47 AM by admot. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-18-2009 01:41 PM

    • admot
    • Top 500 Contributor
      Male
    • Joined on 08-09-2006
    • USA
    • Posts 51

    Error flag to appear on all controls in repeating section

     Let's say I have a repeating group called FruitBasket and an element called Apples under it. I would like to set up a data validation where if the sum of all apples in all the repeating sections > 10, then flag.

    I tried setting up the following expression:

    sum(/my:FruitBasket/my:Apples) > 10

    However, it flags only on the input that caused it to go over, not on all of them. Also, even if you go to a repeating section w/out the flag and lower the apple count so it is less than 10, the flag still remains on that flagged control until you change its value.

     

    Oddly, I ran into this problem before and I was able to get it to work somehow. I tried several approaches to accomplish this.

    1) I tried sum(xdMath:Nz(my:FruitBasket/my:Apples)) > 10. Same results. I didn't expect any major difference anyway.

    2) Placed in another element called ZeroValue under FruitBasket. I then  used sum(/my:FruitBasket/my:Apples)  + sum(/my:FruitBasket/my:ZeroVale) > 10. Odd as it sounds, this did work in the past in another form. Not working now.

    3) Added another element called AppleTotal. I then placed in a rule under Apples where it set AppleTotal = sum(/my:FruitBasket/my:Apples). Apples then got a data validation that flagged if AppleTotal > 10. Same results.

    I tried combinations of 1,2 and 3. Kinda frustrated it works easily with one form and not the other. I tried doing a search in InfoPathdev but no similar issues.

     

    Any advise would be helpful as I assumed this was a simple setup. Flag on all if sum exceeds a value. 

     

    Thanks!

    Don't grow old regretting the things you didn't do.
  • 09-20-2009 07:44 AM In reply to

    Re: Error flag to appear on all controls in repeating section

    Hi --

    Love your signature tag line, by the way.

    The experience you are now having has been what I've usually seen for data validation. I usually have used code when I want it to behave differently. You don't mention the default for zero value in the form that is working. I'm guessing zero, but may be worth checking to see if you have a difference between the two forms.

    Hilary Stoupa

  • 09-21-2009 07:47 AM In reply to

    • admot
    • Top 500 Contributor
      Male
    • Joined on 08-09-2006
    • USA
    • Posts 51

    Re: Error flag to appear on all controls in repeating section

     

    Thanks. Its actually kinda challenging for me live by it.

     The default of ZeroValue in the old form was 0. In this new form, I tried 0 and other values like 2. In this unique case, using code is not an option due to various legitimate reasons.

     

    But I found a solution! I needed a global sum element/attribute.

    Let's say I have Basket\Fruit\ schema with an element "Apples" under the Fruit group (go fig. No pun intended).

    Seriously though, I then placed an AppleTotal attribute (could have used an element) under Basket. I have a rule on Apples where AppleTotal = sum(nz(my:Basket\my:Fruit\my:Apples)). I believe the entire path in the sum important as well. Finally, have a data validation on Apples where if AppleTotal > 5 then flag.

     

    And it works! 

     

    Thanks again.

    Don't grow old regretting the things you didn't do.
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.