Use Google to find help fast. For example, search on "xpressdox choosefromlist".

The PositionOfRepeater Function

The PositionOfRepeater Function

Consider the commands OnExitSet and OnEnterSet. These commands are only executed during the lifetime of the interview, and also contain conditions which need to be evaluated when the user navigates through the interview.

Also consider the case where you would like certain actions to take place depending on the position of the current repeater. For instance, you might want to issue a warning as soon as the user adds a new Child repeater into the interview, but only if the new Child is not the first one. This might look like this:

«ForEach(Child)»
Name: «Name»
«Footing(Name,                        )»

«OnEnterSet(Name,Name,FootingText,(position() > 2),'You have exceeded the recommended number of children','',EvenWhenNotEmpty)»

«End()»

On the face of it, this would put the “You have exceeded…” message into the footing of data element Name when the position of the new Child repeater is greater than 2.

Unfortunately, the position() function does not operate until the document is being assembled, as it requires the ForEach to be active. There is, however, the XpressDox function PositionOfRepeater() which will do what is required, as follows:

«OnEnterSet(Name,Name,FootingText,(PositionOfRepeater() > 2),'You have exceeded the recommended number of children','',EvenWhenNotEmpty)»

A further feature of this function is easier to describe in the context of an example:

«ForEach(Child)»

Name: «Name»
«ForEach(Pet)»
Pet’s Name: «PetName»
«Footing(PetName,                        )»

«OnEnterSet(PetName,PetName,FootingText,(PositionOfRepeater(../) > 1),'Only the first Child may have a pet!','',EvenWhenNotEmpty)»

«End(Pets)»
«End(Children)»

The “../” refers not to the PetName‘s parent in the XML, but one higher, i.e. to the Child containing that Pet collection.