Using Arcade to link Survey123 data

09-09-2021 11:14 AM
New Contributor II


Forgive me if this is the wrong place to post.

I have a web map that has line work on it. That line work when clicked on brings up a survey123 that is auto-populates with the line name. 

I am trying to link the survey with my line work. So when a user clicks on 'line X', the survey populates, the survey gets submitted, and then the pop-up for 'line X' shows the survey information. 

I was able to use intersect for survey items that have geometry, but is there a function that is essentially 'intersect' but for checking field names?


0 Kudos
2 Replies
MVP Esteemed Contributor

Can you clarify: the survey that is pulled up is not tied to the linework layer, but is a separate layer? If I'm understanding your post correctly, you want that updated value from the survey to then show up in the popup for the original clicked feature?

It is more of an Arcade question than a S123 question.

There is a way to "intersect" based on field using the Filter function.

// Name of feature
var f = $feature.line_name_field

// Get survey layer
var fs = FeatureSetByPortalItem(Portal('your-portal-url', 'itemid-of-survey', 0, ['list', 'of', 'survey', 'fields', 'created_date'], false)

// Filter survey responses for those applying to clicked line
var filt_fs = Filter(fs, "line_name_field = @f")

// Check length of filtered featureset, return generic message if none found
if(Count(filt_fs) == 0){
    return 'No surveys for selected feature'

You'll need to think about whether and how you want to deal with multiple surveys for a single feature. Simplest is to just go with a single feature so that the attributes can be accessed. Combining OrderBy and First makes this easy enough.

// Get the single most recent survey
var s = First(OrderBy(filt_fs, 'created_date DESC'))

// Assemble survey attributes into output string
return `Some field: ${s.some_field}, Another field: ${s.another_field}`


- Josh Carlson
Kendall County GIS
New Contributor II

Sorry for the late reply. I figured it out by using a code similar to below....


var moreData = FeatureSetByPortalItem(Portal
'ItemID', LayerID)

var PROJECT = $feature["PROJECT_TI"]

var filterStatement = 'project = @PROJECT'

var relatedData = filter(moreData, filterStatement)
var relatedDataSorted = OrderBy(relatedData, 'CreationDate dsc')

var popUpString =''
for (var f in relatedDataSorted){
    popupString += Text(f.rating + ' Star') + TextFormatting.NewLine

DefaultValue(popupString, 'No comment')
0 Kudos