Index
Video Courses
Watch structured video courses
Knowledge Base
Visit our User Forum for discussions & solutions
How to use a configured data source with a repeat
Prerequisites: At this stage your data source should already be configured. If not, please see configure a data source discussing how to connect your data source to your template.
There are two distinct ways to use a data source with a repeating block. Both methods use the ChooseFromDataSource and ForEach commands to produce output, but they differ fundamentally in how the repeat is driven and how the user interacts with the interview.
Method A: Multi-select outside the loop
The 6th parameter on ChooseFromDataSource creates the repeater directly. The user picks all signatories in one go. An example code would look as follows:
«ChooseFromDataSource(Employees,Select the signatory/ies,RefreshNoSave,,AllowSearch,Signatory)»
«ForEach(Signatory)»
«position()». «Name» - «Position» («Department»)
«End(ForEach)»
The 6th parameter on ChooseFromDataSource (defined as “Signatory” above) does two things at once: (1) it enables multi-select in the search dialog; and (2) it populates the repeater from the selection the user has made. A key point here is that the ChooseFromDataSource sits outside (before) the ForEach. The 6th parameter is what ties the aforesaid commands together. It essentially tells XpressDox “create a repeater called ‘Signatory’ with one entry per selection.” The ForEach then simply iterates over that repeater.
Upon running the template, the database icon is immediately visible on the interview.

Once the user clicks on the icon a search dialog is displayed.

The user selects as many options as they want, clicks “OK” and XpressDox automatically creates the number of Signatory instances behind the scenes.

Method B: Single-select inside the loop
In this case, the user picks one employee inside each iteration to act as signatory. Here, the number of repeats is determined by the user adding instances in the interview. An example code would look as follows:
«RepeaterCaption(Signatory,Signatory/ies)»
«ForEach(Signatory)»
«ChooseFromDataSource(Employees,Select the signatory/ies,RefreshNoSave,,AllowSearch)»
«position()». «Name» - «Position» («Department»)
«End(ForEach)»
In this approach there is no Repeat Container. Instead, the repeater is driven by the user selecting items from the data source inside the repeat one at a time.

Inside each repeat, the user is able to click on the icon and a search dialog is displayed.

The user picks one employee and clicks “OK”.

If the user would like to include an additional employee, they can click on the “Confirm and add next” to add a new repeat or simply click “Confirm” when they have added all employees.

Both methods are correct and will produce the desired output. It is up to you to choose how you prefer to use a data source with a repeat.