<?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 Arcade Script Error in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500033#M45251</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set an Attribute Rule in ArcPro.&amp;nbsp; I am receiving "Invalid expression. Error on line 1. Field not found Cleanliness_Rating.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanFox_0-1719860917242.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108492iAAC52BB77835F634/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanFox_0-1719860917242.png" alt="RomanFox_0-1719860917242.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a field (Cleanliness_Rating) with a text value (from a Domain) of 1-xyzxyzx... , and I want it to slice the first value (1) and return it as a number.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanFox_1-1719860978618.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108493i8DDEB7D06E476956/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanFox_1-1719860978618.png" alt="RomanFox_1-1719860978618.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have test data in the fields.&amp;nbsp; Am I missing something that will allow the field to be found?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2024 19:13:09 GMT</pubDate>
    <dc:creator>RomanFox</dc:creator>
    <dc:date>2024-07-01T19:13:09Z</dc:date>
    <item>
      <title>Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500033#M45251</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to set an Attribute Rule in ArcPro.&amp;nbsp; I am receiving "Invalid expression. Error on line 1. Field not found Cleanliness_Rating.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanFox_0-1719860917242.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108492iAAC52BB77835F634/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanFox_0-1719860917242.png" alt="RomanFox_0-1719860917242.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a field (Cleanliness_Rating) with a text value (from a Domain) of 1-xyzxyzx... , and I want it to slice the first value (1) and return it as a number.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanFox_1-1719860978618.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/108493i8DDEB7D06E476956/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanFox_1-1719860978618.png" alt="RomanFox_1-1719860978618.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have test data in the fields.&amp;nbsp; Am I missing something that will allow the field to be found?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 19:13:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500033#M45251</guid>
      <dc:creator>RomanFox</dc:creator>
      <dc:date>2024-07-01T19:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500059#M45252</link>
      <description>&lt;P&gt;Try using bracket notation, &lt;STRONG&gt;$feature['Cleanliness_Rating']&lt;/STRONG&gt;. Dot notation works &lt;EM&gt;most &lt;/EM&gt;of the time, but bracket notation works &lt;EM&gt;all &lt;/EM&gt;the time.&lt;/P&gt;&lt;P&gt;Also, Arcade isn't Python, so it's really not going to work that way. What you want is the text function&amp;nbsp;&lt;STRONG&gt;Mid &lt;/STRONG&gt;for getting text out from the string, or &lt;STRONG&gt;Left&lt;/STRONG&gt; to get the first character. Try this instead:&lt;/P&gt;&lt;PRE&gt;Left($feature['Cleanliness_Rating'], 1)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 20:16:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500059#M45252</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-07-01T20:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500061#M45253</link>
      <description>&lt;P&gt;Two quick thoughts:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Arcade might not like a space between Text(), if there is one.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;you could try using Left() instead of slice to see if that would give you the expected result. I am not familiar with 'slice' but also Split() may give you the answer you are looking for too. People tend to stay away from left() because it's not as precise as Split() though. Example w/ left():&lt;PRE&gt;&lt;SPAN class=""&gt;var&lt;/SPAN&gt; firstchar = &lt;SPAN class=""&gt;$feature&lt;/SPAN&gt;.cleanliness_rating;&lt;BR /&gt;var&amp;nbsp;extractsubstring&amp;nbsp;=&amp;nbsp;Left(firstchar,1);&lt;BR /&gt;var&amp;nbsp;result&amp;nbsp;=&amp;nbsp;Number(extractsubstring);&lt;BR /&gt;return&amp;nbsp;result;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 20:21:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500061#M45253</guid>
      <dc:creator>doyle2jm</dc:creator>
      <dc:date>2024-07-01T20:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500181#M45254</link>
      <description>&lt;P&gt;You mentioned you are using domain for that field:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;I have a field (Cleanliness_Rating) with a text value (from a Domain) of 1-xyzxyzx...&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;To get the descriptive value, you should use&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;DomainName&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;'Cleanliness_Rating'&lt;/SPAN&gt;&lt;SPAN&gt;), please give it a try.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/feature_functions/#domainname" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/feature_functions/#domainname&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 06:32:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500181#M45254</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2024-07-02T06:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500332#M45255</link>
      <description>&lt;P&gt;This makes sense.&amp;nbsp; I have tried two different configurations of the above idea:&lt;/P&gt;&lt;P&gt;var firstChar = Left($feature['Cleanliness_rating'],1)&lt;BR /&gt;var result= Number(firstChar);&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;This results in "Invalid expression. Error on line1. Object not found cleanliness_rating&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var firstChar = Left($feature['Cleanliness_rating'],1)&lt;BR /&gt;var result= Number(firstChar);&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;This results in "Invalid Expression. No features found."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried the below idea with this:&lt;/P&gt;&lt;P&gt;var firstChar = Cleanliness_Rating($feature,[Cleanliness_rating],1)&lt;BR /&gt;var result= Number(firstChar);&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;The results in "Invalid expression. Error on line 1. Unknown function"&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500332#M45255</guid>
      <dc:creator>RomanFox</dc:creator>
      <dc:date>2024-07-02T14:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500336#M45256</link>
      <description>&lt;P&gt;There wasn't a space after "Text"&lt;/P&gt;&lt;P&gt;The above expression results in the message "Invalid Expression. No features found"&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:35:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500336#M45256</guid>
      <dc:creator>RomanFox</dc:creator>
      <dc:date>2024-07-02T14:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500340#M45257</link>
      <description>&lt;P&gt;I gave that a try:&lt;/P&gt;&lt;P&gt;Cleanliness_Rating($feature. 'cleanliness_rating')&lt;/P&gt;&lt;P&gt;This results in " Invalid expression. Error on line 1. Identifier expected"&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:41:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500340#M45257</guid>
      <dc:creator>RomanFox</dc:creator>
      <dc:date>2024-07-02T14:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500342#M45258</link>
      <description>&lt;P&gt;Yeah, that third option won't work unless you define the function first.&lt;/P&gt;&lt;P&gt;Those errors on the first two seem strange. Are you positive you're typing the field name correctly?&lt;/P&gt;&lt;P&gt;Let's do some debugging. Can you add some Console statements to the top of your expression and see what it spits out?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Console($feature)

for (var attribute in $feature) {
  Console(attribute, $feature[attribute])
}

Console($feature['Cleanliness_rating'])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500342#M45258</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-07-02T14:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Script Error</title>
      <link>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500381#M45259</link>
      <description>&lt;P&gt;Alright, my test data was corrupted.&amp;nbsp; I reloaded the data and we are good to go.&amp;nbsp; The below expression is valid and functioning:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var firstChar = Left($feature['Cleanliness_rating'],1)&lt;BR /&gt;var result= Number(firstChar);&lt;BR /&gt;result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you everyone for the help.&amp;nbsp; I learn something new everyday.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 15:45:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/arcade-script-error/m-p/1500381#M45259</guid>
      <dc:creator>RomanFox</dc:creator>
      <dc:date>2024-07-02T15:45:26Z</dc:date>
    </item>
  </channel>
</rss>

