<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Arcade to link Survey123 data in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1096885#M37081</link>
    <description>&lt;P&gt;Can you clarify: the survey that is pulled up is &lt;EM&gt;not &lt;/EM&gt;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?&lt;/P&gt;&lt;P&gt;It is more of an Arcade question than a S123 question.&lt;/P&gt;&lt;P&gt;There is a way to "intersect" based on field using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#filter" target="_blank"&gt;Filter&lt;/A&gt; function.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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'
}&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;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 &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#orderby" target="_blank"&gt;OrderBy&lt;/A&gt; and &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#first" target="_blank"&gt;First&lt;/A&gt; makes this easy enough.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 18:29:55 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-09-09T18:29:55Z</dc:date>
    <item>
      <title>Using Arcade to link Survey123 data</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1096877#M37080</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Forgive me if this is the wrong place to post.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 18:14:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1096877#M37080</guid>
      <dc:creator>ColtonPhillips</dc:creator>
      <dc:date>2021-09-09T18:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to link Survey123 data</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1096885#M37081</link>
      <description>&lt;P&gt;Can you clarify: the survey that is pulled up is &lt;EM&gt;not &lt;/EM&gt;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?&lt;/P&gt;&lt;P&gt;It is more of an Arcade question than a S123 question.&lt;/P&gt;&lt;P&gt;There is a way to "intersect" based on field using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#filter" target="_blank"&gt;Filter&lt;/A&gt; function.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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'
}&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;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 &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#orderby" target="_blank"&gt;OrderBy&lt;/A&gt; and &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#first" target="_blank"&gt;First&lt;/A&gt; makes this easy enough.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// 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}`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 18:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1096885#M37081</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-09T18:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Arcade to link Survey123 data</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1103202#M37675</link>
      <description>&lt;P&gt;Sorry for the late reply. I figured it out by using a code similar to below....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;
var moreData = FeatureSetByPortalItem(Portal
('https://maps.arcgis.com/'),
'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')&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Sep 2021 18:15:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/using-arcade-to-link-survey123-data/m-p/1103202#M37675</guid>
      <dc:creator>ColtonPhillips</dc:creator>
      <dc:date>2021-09-29T18:15:32Z</dc:date>
    </item>
  </channel>
</rss>

