<?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 Using an Array in the for loop of an Arcade Expression in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441106#M11638</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying (unsuccessfully) to use an Array in my for loop to return the unique route (along with other columns) that is in a related customer table.&amp;nbsp;&amp;nbsp;See example below...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/497183_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;The top table is my customers table (i.e. related table), and the bottom table is my point feature class.&amp;nbsp; The related fields are "CO_ID = CONNECTION_OBJECT".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my Arcade expression...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var tbl = FeatureSetByPortalItem(Portal('https://organization.com/'), 'ItemID', 1);&lt;BR /&gt;Console(Count(tbl));&lt;BR /&gt;var id = $feature["CO_ID"];&lt;BR /&gt;Console(id);&lt;BR /&gt;var sql = "CONNECTION_OBJECT = '" + id + "'";&lt;BR /&gt;Console(sql);&lt;BR /&gt;var customers = Filter(tbl, sql);&lt;BR /&gt;var myArray = customers;&lt;BR /&gt;var cnt = Count(customers);&lt;BR /&gt;Console(cnt);&lt;BR /&gt;var result = "";&lt;BR /&gt;if (cnt &amp;gt; 0) {&lt;BR /&gt; for (var k in myArray) {&lt;BR /&gt;/* var ROUTE = myArray[0];&lt;BR /&gt; console(ROUTE);&lt;BR /&gt; result += TextFormatting.NewLine + "Routes: " + ROUTE +&lt;BR /&gt;*/ result += TextFormatting.NewLine + k;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} else {&lt;BR /&gt; result = "No customer data"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Console(result);&lt;BR /&gt;return result;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens is that I get the right ID and count of related records, but I keep getting the last record (in my customers table) repeating 4 times, with the same route "R003N".&amp;nbsp; What I am trying to get is something that looks like this for the popup...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Address: 123 Main St&lt;/P&gt;&lt;P&gt;Customer: John Doe&lt;/P&gt;&lt;P&gt;Business Partner Number: 111111111&lt;/P&gt;&lt;P&gt;Contract Account: 222222222&lt;/P&gt;&lt;P&gt;Routes:&lt;/P&gt;&lt;P&gt;F0001 / [CommSup]&amp;nbsp;/ M&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FC01&amp;nbsp;/ [CommSup]&amp;nbsp;/ F&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GL01 / [CommSup] / M&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;R003 / [CommSup]&amp;nbsp;/ M&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&amp;nbsp; Let me know if you have any questions or need further clarification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Jun 2020 01:15:08 GMT</pubDate>
    <dc:creator>DonSjoboen</dc:creator>
    <dc:date>2020-06-19T01:15:08Z</dc:date>
    <item>
      <title>Using an Array in the for loop of an Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441106#M11638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying (unsuccessfully) to use an Array in my for loop to return the unique route (along with other columns) that is in a related customer table.&amp;nbsp;&amp;nbsp;See example below...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/497183_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;The top table is my customers table (i.e. related table), and the bottom table is my point feature class.&amp;nbsp; The related fields are "CO_ID = CONNECTION_OBJECT".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my Arcade expression...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var tbl = FeatureSetByPortalItem(Portal('https://organization.com/'), 'ItemID', 1);&lt;BR /&gt;Console(Count(tbl));&lt;BR /&gt;var id = $feature["CO_ID"];&lt;BR /&gt;Console(id);&lt;BR /&gt;var sql = "CONNECTION_OBJECT = '" + id + "'";&lt;BR /&gt;Console(sql);&lt;BR /&gt;var customers = Filter(tbl, sql);&lt;BR /&gt;var myArray = customers;&lt;BR /&gt;var cnt = Count(customers);&lt;BR /&gt;Console(cnt);&lt;BR /&gt;var result = "";&lt;BR /&gt;if (cnt &amp;gt; 0) {&lt;BR /&gt; for (var k in myArray) {&lt;BR /&gt;/* var ROUTE = myArray[0];&lt;BR /&gt; console(ROUTE);&lt;BR /&gt; result += TextFormatting.NewLine + "Routes: " + ROUTE +&lt;BR /&gt;*/ result += TextFormatting.NewLine + k;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;} else {&lt;BR /&gt; result = "No customer data"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Console(result);&lt;BR /&gt;return result;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens is that I get the right ID and count of related records, but I keep getting the last record (in my customers table) repeating 4 times, with the same route "R003N".&amp;nbsp; What I am trying to get is something that looks like this for the popup...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Address: 123 Main St&lt;/P&gt;&lt;P&gt;Customer: John Doe&lt;/P&gt;&lt;P&gt;Business Partner Number: 111111111&lt;/P&gt;&lt;P&gt;Contract Account: 222222222&lt;/P&gt;&lt;P&gt;Routes:&lt;/P&gt;&lt;P&gt;F0001 / [CommSup]&amp;nbsp;/ M&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FC01&amp;nbsp;/ [CommSup]&amp;nbsp;/ F&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GL01 / [CommSup] / M&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;R003 / [CommSup]&amp;nbsp;/ M&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&amp;nbsp; Let me know if you have any questions or need further clarification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jun 2020 01:15:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441106#M11638</guid>
      <dc:creator>DonSjoboen</dc:creator>
      <dc:date>2020-06-19T01:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using an Array in the for loop of an Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441107#M11639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;A href="https://community.esri.com/migrated-users/358745"&gt;Don Sjoboen&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quick question; is the field&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;CONNECTION_OBJECT numeric or string? If it is numeric you should omit the quotes around the ID when you construct the SQL.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2020 13:56:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441107#M11639</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-06-24T13:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using an Array in the for loop of an Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441108#M11640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field [CONNECTION_OBJECT] is an integer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2020 14:23:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441108#M11640</guid>
      <dc:creator>DonSjoboen</dc:creator>
      <dc:date>2020-06-24T14:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using an Array in the for loop of an Arcade Expression</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441109#M11641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/358745" target="_blank"&gt;Don Sjoboen&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you try changing the "sql" like this?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;FeatureSetByPortalItem&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Portal&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'https://organization.com/'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ItemID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; id &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; $feature&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CO_ID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"CONNECTION_OBJECT = "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; id&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; customers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Filter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; myArray &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; customers&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; cnt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;customers&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cnt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;cnt &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; k &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; myArray&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;/* var ROUTE = myArray[0];
    console(ROUTE);
    result += TextFormatting.NewLine + "Routes: " + ROUTE +*/&lt;/SPAN&gt; 
    result &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; TextFormatting&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;NewLine &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"No customer data"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/using-an-array-in-the-for-loop-of-an-arcade/m-p/441109#M11641</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T19:44:57Z</dc:date>
    </item>
  </channel>
</rss>

