In Survey123, a common workflow is allowing users to select multiple locations or areas (for example, administrative boundaries, service areas, zones) and automatically populate the geometry for each selected item inside a repeat.
This is achievable today using calculated expressions, but the approach is advanced, undocumented, and fragile, making it difficult for many form authors to implement correctly.
Current working pattern
The following XLSForm structure is used to calculate polygon geometry based on each selected value from a select_multiple question:
type name label repeat_count calculation appearance
| select_multiple location_list | selected_locations | Select all applicable locations | | | horizontal-compact |
| begin_repeat | locations | Locations | count-selected(${selected_locations}) | | |
| calculate | location_code | | | selected-at(${selected_locations}, position(..)-1) | |
| geoshape | location_shape | Shape | | pulldata("@layer","getValue","geometry","<feature_layer_url>", concat("<location_id_field>='", ${location_code}, "'")) | |
| end_repeat | | | | | |
This pattern relies on:
count-selected() to dynamically create repeat instances
selected-at() with position(..) to map each repeat to one selected value
pulldata("@layer","getValue","geometry",…) to retrieve geometry from a feature layer