<?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 Get Field Value Using Variable in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233453#M62444</link>
    <description>&lt;P&gt;Sorry, did not post correctly, but I updated it.&lt;/P&gt;&lt;P&gt;Sounds like you got the important part about listing the fields that will be used and got it working.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2022 23:02:12 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2022-11-18T23:02:12Z</dc:date>
    <item>
      <title>Arcade Get Field Value Using Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233362#M62424</link>
      <description>&lt;P&gt;Need some help understanding Arcade's syntax. The top two lines throw an error, as shown. The bottom one works fine. I'd prefer to not hard-code field names, so using the bracket syntax with a variable would be preferable to the dot notation ($feature.COLOR).&amp;nbsp;What am I missing here?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinceE_0-1668790229249.png" style="width: 443px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56361i1D9A437F62712B31/image-dimensions/443x249?v=v2" width="443" height="249" role="button" title="VinceE_0-1668790229249.png" alt="VinceE_0-1668790229249.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VinceE_1-1668790291933.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56362i13026D60811D168C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VinceE_1-1668790291933.png" alt="VinceE_1-1668790291933.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 19:23:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233362#M62424</guid>
      <dc:creator>VinceE</dc:creator>
      <dc:date>2022-11-18T19:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Get Field Value Using Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233448#M62442</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Expects($feature, 'COLOR')
var fieldName = 'COLOR'

$feature[fieldName]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As seen &lt;A href="https://developers.arcgis.com/arcade/guide/variables/" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 23:09:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233448#M62442</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-11-18T23:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Get Field Value Using Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233449#M62443</link>
      <description>&lt;P&gt;Very helpful, thanks. Seems like I was missing the part where it is necessary to declare the attribute variables from the table that are to be used in the script...?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Expects($feature, 'COLOR')
//$feature.COLOR;

var fieldName = 'COLOR'
return $feature[fieldName]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation, found at the link you provided:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;You should explicitly list all field attributes that will be used at the top of the expression. This will ensure the profile will request the appropriate data from required fields so the expression evaluates properly.&lt;/EM&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;$feature.COLLEGE;&lt;/SPAN&gt;&lt;SPAN&gt;$feature.POPULATION;&lt;/SPAN&gt;
&lt;SPAN&gt;Round(($feature.COLLEGE / $feature.POPULATION) * 100, 2);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;EM&gt;&lt;SPAN&gt;Alternatively, you may use the&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/feature_functions/#expects" target="_blank" rel="noopener"&gt;Expects&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;function for this purpose.&lt;/SPAN&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN&gt;Expects($feature, "COLLEGE", "POPULATION");&lt;/SPAN&gt;
&lt;SPAN&gt;Round(($feature.COLLEGE / $feature.POPULATION) * 100, 2);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Nov 2022 23:07:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233449#M62443</guid>
      <dc:creator>VinceE</dc:creator>
      <dc:date>2022-11-18T23:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Get Field Value Using Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233453#M62444</link>
      <description>&lt;P&gt;Sorry, did not post correctly, but I updated it.&lt;/P&gt;&lt;P&gt;Sounds like you got the important part about listing the fields that will be used and got it working.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 23:02:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-get-field-value-using-variable/m-p/1233453#M62444</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-11-18T23:02:12Z</dc:date>
    </item>
  </channel>
</rss>

