<?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: Arcade EVAL function - evaluate a string to retrieve field value in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-eval-function-evaluate-a-string-to-retrieve/m-p/1316542#M53803</link>
    <description>&lt;P&gt;When using a variable as a field name, you have to use &lt;A href="https://developers.arcgis.com/arcade/guide/variables/#bracket-notation" target="_self"&gt;bracket notation&lt;/A&gt; to get the attribute of that field. You can also use &lt;A href="https://developers.arcgis.com/arcade/guide/template-literals/" target="_self"&gt;template literals&lt;/A&gt; to construct your strings. And when &lt;A href="https://developers.arcgis.com/arcade/guide/loops/#array" target="_self"&gt;looping through an array&lt;/A&gt;, the variable is just the index. You have to get the value of the array at that index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;html = '&amp;lt;html table header stuff&amp;gt;';
var daynames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
for (var d in daynames) {
    html += `&amp;lt;tr&amp;gt;${daynames[d]}: ${$feature[daynames[d]]}&amp;lt;/tr&amp;gt;`;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 17:57:13 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-08-08T17:57:13Z</dc:date>
    <item>
      <title>Arcade EVAL function - evaluate a string to retrieve field value</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-eval-function-evaluate-a-string-to-retrieve/m-p/1316531#M53801</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm looking for a way to construct a field name in Arcade and retrieve its value.&amp;nbsp; Say you have a hosted feature layer with an attribute field named after each day of the week.&amp;nbsp; I can construct the field name as "$feature.insertDayHere" but that is just a string that I need to evaluate to get the value.&amp;nbsp; Does Arcade have any kind of EVAL function?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;html = '&amp;lt;html table header stuff&amp;gt;';&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;daynames&lt;/SPAN&gt;&lt;SPAN&gt; = [&lt;/SPAN&gt;&lt;SPAN&gt;"Sunday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Monday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Tuesday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Wednesday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Thursday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Friday"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"Saturday"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt;&amp;nbsp;d&amp;nbsp;&lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;daynames&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;fieldname&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'$feature.'&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;/SPAN&gt;&lt;SPAN&gt;d&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;html&lt;/SPAN&gt;&lt;SPAN&gt; += '&amp;lt;tr&amp;gt;' +&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;d&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;+ &lt;/SPAN&gt;&lt;SPAN&gt;': '&lt;/SPAN&gt;&lt;SPAN&gt; + &lt;STRONG&gt;fieldna&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;me&lt;/STRONG&gt; + '&amp;lt;/tr&amp;gt;'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 08 Aug 2023 17:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-eval-function-evaluate-a-string-to-retrieve/m-p/1316531#M53801</guid>
      <dc:creator>KevinMayall</dc:creator>
      <dc:date>2023-08-08T17:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade EVAL function - evaluate a string to retrieve field value</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-eval-function-evaluate-a-string-to-retrieve/m-p/1316542#M53803</link>
      <description>&lt;P&gt;When using a variable as a field name, you have to use &lt;A href="https://developers.arcgis.com/arcade/guide/variables/#bracket-notation" target="_self"&gt;bracket notation&lt;/A&gt; to get the attribute of that field. You can also use &lt;A href="https://developers.arcgis.com/arcade/guide/template-literals/" target="_self"&gt;template literals&lt;/A&gt; to construct your strings. And when &lt;A href="https://developers.arcgis.com/arcade/guide/loops/#array" target="_self"&gt;looping through an array&lt;/A&gt;, the variable is just the index. You have to get the value of the array at that index.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;html = '&amp;lt;html table header stuff&amp;gt;';
var daynames = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
for (var d in daynames) {
    html += `&amp;lt;tr&amp;gt;${daynames[d]}: ${$feature[daynames[d]]}&amp;lt;/tr&amp;gt;`;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 17:57:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-eval-function-evaluate-a-string-to-retrieve/m-p/1316542#M53803</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-08T17:57:13Z</dc:date>
    </item>
  </channel>
</rss>

