validate unique values across repeating groups

W

Will

I often want to validate that a certain attribute or child element is
unique across repeating groups. Based on information from previous
threads, I was able to accomplish this by creating a validation
condition on the uniqueField control:

". = ../preceding-sibling::groupName/uniqueField or
. = ../following-sibling::groupName/uniqueField"

This works okay. However, I run across the following problem:

I set uniqueField to "01" on row A. Then I set uniqueField to "01" on
row B. This triggers the validation error on uniqueField of row B.
Now if I go back and change uniqueField to "02" on row A, the error
(red outline) on row B remains. To remove the error, I must change
uniqueField on row B to something else, then change it back to "01" to
retrigger the validation.

Does anyone know a way to enforce this validation in a more global
manner (without adding too much complexity)?

Thanks,
Will
 
G

Greg Collins [InfoPath MVP]

Unfortunately, you've just enetered the world of complexity :eek:).

I've tried doing the same thing many times. InfoPath watches errors in one direction, not two. Thus the situation you run into where if you update the "wrong" field, the error doesn't go away.

An alternative do using data validation is to do all of this in code. It might be a little more work up front, but you can fine tune it much easier to accomplish what you want. The code would add or delete errors as necessary and can make sure that both fields are appropriately udpated.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I often want to validate that a certain attribute or child element is
unique across repeating groups. Based on information from previous
threads, I was able to accomplish this by creating a validation
condition on the uniqueField control:

". = ../preceding-sibling::groupName/uniqueField or
. = ../following-sibling::groupName/uniqueField"

This works okay. However, I run across the following problem:

I set uniqueField to "01" on row A. Then I set uniqueField to "01" on
row B. This triggers the validation error on uniqueField of row B.
Now if I go back and change uniqueField to "02" on row A, the error
(red outline) on row B remains. To remove the error, I must change
uniqueField on row B to something else, then change it back to "01" to
retrigger the validation.

Does anyone know a way to enforce this validation in a more global
manner (without adding too much complexity)?

Thanks,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top