Select to view content in your preferred language

Filtering Survey123 Repeat Table Points to a Single Submission on Report Maps

269
0
2 weeks ago
Sunil_Ghimire
Emerging Contributor

Filter Survey123 Report Map to Single Submission's Repeat Points

Step-by-step guide to filtering Survey123 report maps using mapFilters so each PDF shows only the repeat table points belonging to that submission.

If you've ever opened a Survey123 feature report and watched your map render every geopoint ever collected — instead of just the current submission's — you know the frustration. The fix isn't in the documentation in any clear way. This guide walks through every step needed to filter the report map down to a single submission, cleanly framed and free of overlapping pins.


The Scenario

A typical Survey123 form:

  • A parent record representing one inspection, site visit, or job
  • A repeat group inside the form that collects multiple geopoints (test locations, defects, observations)
  • A feature report template in Word (.docx) that produces a PDF per submission, including a map of the collected points

The goal: filter the map to only the points belonging to the parent record being reported on.


Step 1: Prepare a Dedicated Report Web Map

In ArcGIS Online or Portal, create a new web map and add the repeat's point feature layer as an operational layer. Optionally include the parent layer or reference layers if they should appear on the report map.

Configure the basemap and layer styling exactly as the report should display them. Save the web map and confirm it is shared at least with the organization that owns the survey — the report engine cannot render a private web map. Every operational layer inside the web map must be shared at the same level.


Step 2: Find the Operational Layer ID

The layer ID needed for mapFilters is not the feature service index (0, 1, 2). It is an internal identifier that looks like 19abc1234de-layer-5 and lives inside the web map's JSON. There are two ways to find it.

Method 1: Direct REST URL

Open the web map's JSON definition in a browser:

https://www.arcgis.com/sharing/rest/content/items/WEB_MAP_ITEM_ID/data?f=pjson

Search the response for the title of the repeat layer. The entry will look like this:

{
  "id": "19abc1234de-layer-5",
  "title": "inspections_repeat",
  "url": "https://services.../FeatureServer/1",
  ...
}

Method 2: Browser Developer Tools

Open the web map in the ArcGIS Map Viewer, then open browser developer tools (F12 in most browsers) and switch to the Network tab. Reload the page. In the list of network requests, look for a call ending in /data or filter the list by typing data in the search box. Click the matching request and view its Response tab. The response is the same JSON structure shown above — search inside it for the repeat layer's title to find its id.

This method is useful when the REST URL is not easily accessible or when working inside an Enterprise environment where the AGOL-style URL doesn't apply.

What to copy

From either method, the value of "id" is what goes inside mapFilters. Confirm the "url" field next to it points at the correct feature service index for the repeat points layer.


Step 3: Identify the Parent–Child Relationship

The relationship between the parent record and the repeat records is the foundation of the filter. To inspect it, open the feature service's relationships endpoint:

https://YOUR_SERVICE_URL/FeatureServer/relationships?f=pjson

The response will contain JSON like this:

{
  "relationships": [{
    "originPrimaryKey": "globalid",
    "originForeignKey": "parentglobalid",
    ...
  }]
}

Two values matter:

  • originPrimaryKey — the identifier on the parent layer (typically globalid)
  • originForeignKey — the field on the child layer that points back at the parent (typically parentglobalid)

For most Survey123 forms built in the web designer, the relationship is globalid → parentglobalid. Surveys built in Survey123 Connect with GUID relationships may use uniquerowid → parentrowid instead. Always check the relationship endpoint rather than assuming.


Step 4: Add a Blank Reference Layer to Suppress the Centering Pin

When the report engine renders a centered map, it places a default pin at the centering geometry. This pin overlaps the actual data point and creates a visual conflict.

To hide it cleanly, add a separate polygon feature layer to the web map with no visible symbology (transparent fill, no outline). The expression in Step 6 will reference this layer to suppress the pin. Note its feature service URL — typically ending in /FeatureServer/N where N is the layer index.


Step 5: Build the Filter Expression

The expression combines four pieces: the web map ID, the operational layer ID, the relationship field, and a centering strategy. The recommended pattern uses a repeat block to anchor centering on the first point's geometry:

${#repeat_name | orderByFields:"objectid ASC" | resultRecordCount:1}
${$shape 
  | map:"WEB_MAP_ITEM_ID" 
  | mapFilters:"'LAYER_ID':where=parentglobalid='"+parentglobalid+"'" 
  | drawingInfo:"BLANK_LAYER_URL" 
  | mapScale:2000 
  | size:600:600}
${/}

Breaking it down:

  • ${#repeat_name ... resultRecordCount:1} enters the repeat block but limits processing to the first row
  • $shape uses that first row's geometry as the map center
  • map references the report web map
  • mapFilters applies the SQL where clause to the specified layer
  • parentglobalid='"+parentglobalid+"' injects the current parent's identifier so only this submission's points render
  • drawingInfo suppresses the default centering pin by referencing the blank layer
  • mapScale:2000 sets a tight zoom (lower number = more zoomed in)
  • size:600:600 sets the map image resolution

Step 6: Replace the Placeholders

In the expression, replace these placeholders with values from the prior steps:

  • repeat_name — the XLSForm name of the repeat group
  • WEB_MAP_ITEM_ID — the report web map's item ID (from its AGOL page)
  • LAYER_ID — the operational layer ID from Step 2
  • parentglobalid — the originForeignKey from Step 3 (or parentrowid for Connect surveys)
  • BLANK_LAYER_URL — the feature service URL of the blank layer from Step 4

The value parentglobalid appears twice — once as the field name in the where clause and once as the placeholder being injected. Both must match the relationship's foreign key field.


Step 7: Tune the Map Output

Adjust the final parameters based on report layout needs.

mapScale controls zoom. Smaller values zoom in tighter. Typical values:

  • 1000 — block level
  • 2000 — building / site level
  • 5000 — neighborhood
  • 10000 — district
  • 25000 — small city

size controls image resolution. Higher values produce sharper output:

  • 600:600 — small inline maps
  • 1200:1200 — half-page maps
  • 1600:1600 — full-page or high-detail reports

Match the aspect ratio of size to the Word cell that holds the map (a square size stretched into a rectangular cell will distort).

For CAD basemaps, match mapScale to the scale the basemap was authored at. A basemap designed for 1:2000 will render poorly at 1:50000.


The Final Expression

${#repeat_name | orderByFields:"objectid ASC" | resultRecordCount:1}
${$shape 
  | map:"WEB_MAP_ITEM_ID" 
  | mapFilters:"'LAYER_ID':where=parentglobalid='"+parentglobalid+"'" 
  | drawingInfo:"BLANK_LAYER_URL" 
  | mapScale:2000 
  | size:600:600}
${/}

With the placeholders filled in, this expression produces a clean map showing only the points from a single Survey123 submission, framed tightly around the data with no overlapping centering pin.


Summary

Filtering Survey123 report maps to a single submission requires four components aligned correctly:

  1. A dedicated web map containing the repeat points layer as an operational layer
  2. The correct operational layer ID from the web map JSON
  3. The correct field pair from the feature service relationships endpoint
  4. A blank reference layer to suppress the default centering pin

Once these are in place, the expression generalizes across surveys of any complexity — multi-repeat, nested, or with parent-level geopoints layered alongside the repeat data.

0 Kudos
0 Replies