Validate against First Field of a Repeating Section - InfoPath Dev
in

InfoPath Dev

Validate against First Field of a Repeating Section

Last post 05-20-2013 02:13 PM by Baseball17Bucks. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-20-2013 06:29 AM

    Validate against First Field of a Repeating Section

    Hi,

     I have a repeating section called "YearlySpendingPlans". In that section there is a field "YearlyTotal".

    Outside of this section, there is a field called "RequiredFundsTotal". (FYI the way the form works is that I want a check between what the user "wants" and what they "need" to do the work they are proposing to do. The RequiredFundsTotal field looks at funds required for this year. On the other hand, the spending plans are developed for this year AND future years. )

    I want to put a Validation Rule on "Required Funds Total" (which looks at funds for this year) to check for equality against the first "YearlyTotal" field in the repeating table. I've tried the following logic...

    Validate "RequiredFundsTotal" --> condition: Is not equal to --> ../../../my:SpendPlanBucket/my:YearlySpendingPlans/my:YearlySpendingPlan[count(preceding-sibling::*) + 1]/my:YearlyTotals/my:YearlyTotal

    Here I'm trying to reference the [count(preceding-sibling::*) + 1] index of the repeating section, which my understanding is the first occurence of the YearlySpendingPlan repeating section.

     Unfortunately, I'm not getting this validation to work.

     Thanks for the help!!!

     - JF

  • 05-20-2013 07:59 AM In reply to

    Re: Validate against First Field of a Repeating Section

    Hi Baseball17Bucks,

       I think that, if anything, [count(preceding-sibling::*) + 1] would refer to the last row of a repeating group, but there's an easier way to do that as well.

    First row of a repeating group:

       my:YearlySpendingPlan[1]

    Last row of a repeating group:

       my:YearlySpendingPlan[last()]

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-20-2013 02:13 PM In reply to

    Re: Validate against First Field of a Repeating Section

    Found a Fix!

    My understanding of the InfoPath indexing was correct, however the Validation function just seemed to be choking.

    My Solution: Create a field in the repeating table called "Yearly Total". Create a hidden field called "YearlySpendingPlan-ID" in the repeating table group and gave it the Default Value = count(preceding-sibling::*)+1

    Then create the Rule: Validation --> RequiredFundsTotal --> Condition: Is not equal to --> YearlyTotal[YearlySpendingPlan-ID = 1]

    In this logic, I put a filter on YearlyTotal using YearlySpendingPlan-ID as the filter field. Bingo!

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