Hi all
How can I count the number of instances in a repeat and use this as basis for a validation of a number field outside of the repeat?
Use case
I have a number field (= NoChildren) and a repeat (DetailsChildren repeat, collecting first name, last name, birthdate etc per child). I want to make sure that the repeat has the same number of instances as the number field = for every child an instance exists.
Does someone know how to write the validation?
Cheers and thx
Hey @sarah-fresh-flame,
you can use NumberOfFilledGroups (Docu) for this.
This would also count empty repetitions. If the fields are not required you may want to use NumberOfFilledFields(Children*/Firstname) instead. And if you only want to count unique instances: NumberOfDifferentValues(Children*/Firstname). (So “Sarah, Felix, Sarah” would return only 2)
Hi @felix-blazing-river
aweseome, worked perfectly well. And yes, at least some fields in the repeat are always mandatory.
Thanks a lot for the quick help!