How to access repeating table/section fields in Info Path Web Browser Forms

Accessing or validating fields within a repeating table/section using web browser forms might be a little bit tricky, as web browser forms will not allow you to reference specific rows by index, use Last() or Position() functions...
There are some XPath formulas that you can use to access or validate fields within a repeating section with out having to use any extra code in your form.

These are some examples:
  • Check if a repeating section/table has duplicate rows:
count(XpathToRepeatingGroup[following-sibling::*/FieldToBevalidated = FieldToBeValidated]) > 0

If value returned by the XPath expression is greater than 0 then the repeating table contains duplicate rows. The number returned by the XPath expression will be the number of duplicate rows that your repeating section contains.
Do not forget to include in the condition when field is not blank, as blank values count as duplicates.
  • Get the previous row value:
../preceding-sibling::my:RepeatingGroup[count(preceding-sibling:my:RepeatingGroup) = count(current()/../preceding-sibling::my:RepeatingGroup)-1)/my:FieldToGetValue

This function is very useful as will allow you to compare the current row with the previous row or auto-fill the current row with the value of the previous row.
If you use it for validations, I recommend you to create a field within the repeating section that contains the previous row value and use this field to compare with the current row.
  • Last() function, get the last row value:
XpathToRepeatingGroup[count(following-sibling::*[local-name() = "RepeatingGroup"]) = 0]/my:FieldToGetValue
  • Position() function, get the current row index:
count(preceding-sibling::*[local-name() = "RepeatingGroup"])

Note that the words in red refers to your own form structure and fields name.








Comments

  1. thanks for this tip! is there a way we can check if value of repeating column1 is greater than repeating column 2?

    ReplyDelete
  2. Yes, you can access to the value of the previous row by using this function
    preceding-sibling::my:MyRepeatingGroup[count(preceding-sibling::my:MyRepeatingGroup) = count(current()/preceding-sibling::my:MyRepeatingGroup) - 1]/my:FieldToAccess
    Then you just need you compare the previous row with your current row

    ReplyDelete
  3. Whenever I try that formula, it tells me that the formula is invalid. my:MyRepeatingGroup shows up as ".." and that comes up as an error.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to convert fields in lower case/upper case within Info path forms

How to auto save a browser enabled info path form every X minutes in Sharepoint 2007, 2010 and 2013

Auto-populate the person/Group picker from the current user on InfoPath 2007/2010/2013