Index
Video Courses
Watch structured video courses
Knowledge Base
Visit our User Forum for discussions & solutions
SelectFromRepeatingData
Presenting a multi-select checklist from a repeating data group in your XpressDox template by utilising the SelectFromRepeatingData command
This command allows the user to select one or more items from a previously captured repeating data group. It is similar to ChooseFromRepeatingData but instead of a drop-down (single selection), it presents a checklist that allows multiple items to be selected. The selected items are stored as pipe-delimited IDs which can then be used to retrieve data from the source repeater when assembling the document.
Syntax
«SelectFromRepeatingData(FieldToStore,RepeaterName,<DisplayLabel>»
«Caption(FieldToStore,<p>Caption Text</p>)»
| Parameter | Description |
| FieldToStore | The name of the data element in which the selected IDs will be stored. |
| RepeaterName | The name of the ForEach repeater to draw selection items from. Use ../ prefix if selecting from a sibling repeater inside another ForEach. |
| <DisplayLabel> | The text shown to the user for each item in the checklist. Use angle brackets <…> to reference fields from the source repeater. |
Example: Select Employees for a Contract
In this example, a contract title is captured first, followed by a repeating group of employees. Outside the ForEach, SelectFromRepeatingData presents a checklist of all entered employees so the user can select which ones apply to the contract.
«ContractTitle»
«ForEach(Employee)»
«FirstName» «LastName» - «ChooseFromList(Department,,HR,Finance,IT,Operations)»«Department»
«End(Employee)»
«SelectFromRepeatingData(SelectedEmployees,Employee,<FirstName> <LastName> - <Department>)»
«Caption(SelectedEmployees,<p>Select employees for this contract</p>)»
In the interview, the user will enter the Contract Title and fill in one or more Employee entries. After completing the repeating group, the user is presented with a checklist of all entered employees, displayed as e.g. John Smith – Finance. They can select one or more employees. The selected employees IDs are stored in SelectedEmployees as a pipe-delimited string.
When the user makes their selection, XpressDox stores the internal ID of each chosen Employee record in the SelectedEmployees field, separated by a pipe character (e.g. 1|3|5). To print the full details of each selected employee in the document, the template needs to split that string back into individual IDs and use each one to look up the matching Employee record.
The example below shows how this is done:
Contract: «ContractTitle»
Selected Employees:
«ArraySetFromString('IDValues',SelectedEmployees,'|')»«::p»
«SetVr('index',1)»
«RepeatWhile(GetVn('index') <= ArrayCount('IDValues'))»
«Employee[@xd_rpid=ArrayValues('IDValues',getV('index'))]/FirstName» «Employee[@xd_rpid=ArrayValues('IDValues',getV('index'))]/LastName» - «Employee[@xd_rpid=ArrayValues('IDValues',getV('index'))]/Department»
«IncrementVr('index')»
«End()»
Note: This code makes use of arrays, variables and the RepeatWhile command. If you are not familiar with these, please refer to the articles on Arrays, Variables and RepeatWhile before using this pattern.