<?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 Returning 2nd, 3rd....attribute from related table with Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100556#M42252</link>
    <description>&lt;P&gt;After scouring the forums and anything else (since I am just learning this), I have gotten to this place with the below code.&amp;nbsp; I need to return the attribute called "filepath" of the 2nd related record, 3rd related record, etc.&amp;nbsp; I have to do a separate expression for each one, so I can display it is as a URL and Photo in the pop up.&amp;nbsp; I got the first record to work in another expression, but I'm clearly not doing something right here, since this doesn't return anything when I try to get the 2nd or 3rd value.&amp;nbsp; &amp;nbsp;&lt;BR /&gt;--------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;var index = 0;&lt;BR /&gt;var related_table = OrderBy(FeatureSetByRelationshipName($feature,"%vw_EventAttachments"), "AttachmentID");&lt;BR /&gt;&lt;BR /&gt;var filter_query = "EGUID = '" + $feature["EGUID"] + "'";&lt;BR /&gt;var related_data_filtered = Filter(related_table, filter_query);&lt;BR /&gt;var related_data_filtered_count = Count(related_data_filtered);&lt;BR /&gt;var output = "";&lt;/P&gt;&lt;P&gt;for (var row in related_data_filtered) {&lt;/P&gt;&lt;P&gt;if (related_data_filtered_count &amp;gt; 0)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;index++;&lt;BR /&gt;&lt;BR /&gt;if (index == 2)&lt;BR /&gt;&lt;BR /&gt;return (related_data_filtered).Filepath;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;else { output = " ";}&lt;/P&gt;&lt;P&gt;return output;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 21 Sep 2021 20:57:46 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-09-21T20:57:46Z</dc:date>
    <item>
      <title>Returning 2nd, 3rd....attribute from related table with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100556#M42252</link>
      <description>&lt;P&gt;After scouring the forums and anything else (since I am just learning this), I have gotten to this place with the below code.&amp;nbsp; I need to return the attribute called "filepath" of the 2nd related record, 3rd related record, etc.&amp;nbsp; I have to do a separate expression for each one, so I can display it is as a URL and Photo in the pop up.&amp;nbsp; I got the first record to work in another expression, but I'm clearly not doing something right here, since this doesn't return anything when I try to get the 2nd or 3rd value.&amp;nbsp; &amp;nbsp;&lt;BR /&gt;--------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;var index = 0;&lt;BR /&gt;var related_table = OrderBy(FeatureSetByRelationshipName($feature,"%vw_EventAttachments"), "AttachmentID");&lt;BR /&gt;&lt;BR /&gt;var filter_query = "EGUID = '" + $feature["EGUID"] + "'";&lt;BR /&gt;var related_data_filtered = Filter(related_table, filter_query);&lt;BR /&gt;var related_data_filtered_count = Count(related_data_filtered);&lt;BR /&gt;var output = "";&lt;/P&gt;&lt;P&gt;for (var row in related_data_filtered) {&lt;/P&gt;&lt;P&gt;if (related_data_filtered_count &amp;gt; 0)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;index++;&lt;BR /&gt;&lt;BR /&gt;if (index == 2)&lt;BR /&gt;&lt;BR /&gt;return (related_data_filtered).Filepath;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;else { output = " ";}&lt;/P&gt;&lt;P&gt;return output;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 20:57:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100556#M42252</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-09-21T20:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Returning 2nd, 3rd....attribute from related table with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100686#M42257</link>
      <description>&lt;P&gt;You are on the right track, your for loop is just a little wonky.&lt;/P&gt;&lt;P&gt;What you're doing is this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;increase index&lt;/LI&gt;&lt;LI&gt;check if it is 2&lt;UL&gt;&lt;LI&gt;yes: return Filepath (and you try to return it from the feature set as opposed to returning it from row)&lt;/LI&gt;&lt;LI&gt;no: set output to " " and return that&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So the code gets to the first row, sees that index = 1 != 2 and returns " ".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Copy this function and change the return_index for each instance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// the number of the row from which you want to return the AttachmentID
// 1 for first, 2 for second, ...
var return_index = 2;

var related_table = OrderBy(FeatureSetByRelationshipName($feature,"%vw_EventAttachments"), "AttachmentID");

var filter_query = "EGUID = '" + $feature["EGUID"] + "'";
var related_data_filtered = Filter(related_table, filter_query);
var related_data_filtered_count = Count(related_data_filtered);

// return early if you want to get an attachment that doesn't exist
if(return_index &amp;gt; related_data_filtered_count) {
  return "";
}

var index = 1;
for (var row in related_data_filtered) {
  if(index == return_index) {
    return row.Filepath;
  }
  index++;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 07:40:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100686#M42257</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-22T07:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Returning 2nd, 3rd....attribute from related table with Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100851#M42264</link>
      <description>&lt;P&gt;Thank you soooo much! It works great.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 15:08:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/returning-2nd-3rd-attribute-from-related-table/m-p/1100851#M42264</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-09-22T15:08:30Z</dc:date>
    </item>
  </channel>
</rss>

