Select to view content in your preferred language

Support calculating geometry from select_multiple choices inside repeats in Survey123

69
0
Tuesday
Status: Open
Labels (3)
Chalhoub
Occasional Contributor

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_listselected_locationsSelect all applicable locations  horizontal-compact
begin_repeatlocationsLocationscount-selected(${selected_locations})  
calculatelocation_code  selected-at(${selected_locations}, position(..)-1) 
geoshapelocation_shapeShape 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