<?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: My arcade code is ending in &amp;quot;Execution Error:Runtime Error:&amp;quot; and I'm not sure why in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147105#M44541</link>
    <description>&lt;P&gt;Hey Josh,&lt;/P&gt;&lt;P&gt;Thank you so much for your response! I tried using the code you wrote and it ended up making everything "Unknown". I then went back to my old code and applied all of your comments and now it's working great! I definitely learned a lot from your response, and I really appreciate that you took the time to write back as I know I'll have to do more coding in the future.&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Ellie&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 17:56:59 GMT</pubDate>
    <dc:creator>EllieHakariAK</dc:creator>
    <dc:date>2022-02-23T17:56:59Z</dc:date>
    <item>
      <title>My arcade code is ending in "Execution Error:Runtime Error:" and I'm not sure why</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147053#M44539</link>
      <description>&lt;P&gt;I'm attempting to change the symbology for the &lt;A href="https://akdot.maps.arcgis.com/home/item.html?id=a0fa29a39fe444ac97d4337c569b9801" target="_self"&gt;National Bridge Inventory&lt;/A&gt; layer. By default, it is set to create symbology based on the Deck Structure field. However, for our purposes we need to base the symbology around an average of Deck Structure, Substructure, and Superstructure. We also want to flag any records where all three of these fields are equal to 5.&lt;/P&gt;&lt;P&gt;I've tried several variations of code, such as using a When statement, creating a function to flag those "5" records, etc. Some have ended in errors, others have produced bad results such as symbolizing everything as "Unknown". Right now, my code consists of several if/else statements:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var c = $feature["DECK_COND_058"]
var ss = $feature["SUPERSTRUCTURE_COND_059"]
var sb = $feature["SUBSTRUCTURE_COND_060"]
var avg = AVERAGE($feature["DECK_COND_058"], $feature["SUPERSTRUCTURE_COND_059"], $feature["SUBSTRUCTURE_COND_060"])

if((c == 5) &amp;amp;&amp;amp; (ss == 5) &amp;amp;&amp;amp; (sb == 5)) {
    "Fair, soon to be poor";
} else if (Round(avg = 9)) {
    "Excellent to good";
} else if (Round(avg = 8)) {
    "Excellent to good";
} else if (Round(avg = 7)) {
    "Excellent to good";
} else if (Round(avg = 6)) {
    "Satisfactory to fair";
} else if (Round(avg = 5)) { 
    "Satisfactory to fair";
} else if (Round(avg = 4)) { 
    "Poor to critical";
} else if (Round(avg = 3)) {
    "Poor to critical";
} else if (Round(avg = 2)) {
    "Poor to critical";
} else if (Round(avg = 1)) {
    "Failed to imminent failure";
} else if (Round(avg = 0)) {
    "Failed to imminent failure";
} else {
    "Unknown";
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Execution Error:Runtime Error:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not really sure what this means. Any insight? Can you spot any obvious flaws in my code? Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 16:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147053#M44539</guid>
      <dc:creator>EllieHakariAK</dc:creator>
      <dc:date>2022-02-23T16:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: My arcade code is ending in "Execution Error:Runtime Error:" and I'm not sure why</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147080#M44540</link>
      <description>&lt;P&gt;Your conditions need to be written with "==", not "=". The single equals sign would attempt to assign the value to a variable. And it looks like you're trying to check if the rounded average is equal to the value, but you have "avg = 9" &lt;EM&gt;inside &lt;/EM&gt;the Round function.&lt;/P&gt;&lt;PRE&gt;if (Round(avg) == 9)&lt;/PRE&gt;&lt;P&gt;Second, your if/else if/else statements have no &lt;STRONG&gt;return&lt;/STRONG&gt; in them, so that's probably also going to give you errors.&lt;/P&gt;&lt;PRE&gt;if (Round(avg) == 9){&lt;BR /&gt;    &lt;STRONG&gt;return&lt;/STRONG&gt; "Excellent to good";&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;As for the code itself, this can be made a bit more concise. Since the variable &lt;STRONG&gt;avg &lt;/STRONG&gt;is being rounded every time you use it, you may as well round it off at the start. It also looks like some of your conditions evaluate to the same output text, so you can combine those together.&lt;/P&gt;&lt;P&gt;Finally, you might check out the &lt;STRONG&gt;Where&lt;/STRONG&gt; function. As with your if/else if/else statements, conditions in the Where function evaluate in order, so you can simply check if&amp;nbsp;&lt;STRONG&gt;avg&amp;nbsp;&lt;/STRONG&gt;is greater than your threshold values.&lt;/P&gt;&lt;P&gt;Here's how I might re-write your expression.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var c = $feature["DECK_COND_058"]
var ss = $feature["SUPERSTRUCTURE_COND_059"]
var sb = $feature["SUBSTRUCTURE_COND_060"]
var avg = Round(Average([c, ss, sb]))

return When(
    c == 5 &amp;amp;&amp;amp; s == 5 &amp;amp;&amp;amp; sb == 5, 'Fair, soon to be poor',
    avg &amp;gt; 6, 'Excellent to good',
    avg &amp;gt; 4, 'Satisfactory to fair',
    avg &amp;gt; 1, 'Poor to critical',
    avg == 1 || avg == 0, 'Failed to imminent failure',
    'unknown'
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 17:29:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147080#M44540</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-23T17:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: My arcade code is ending in "Execution Error:Runtime Error:" and I'm not sure why</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147105#M44541</link>
      <description>&lt;P&gt;Hey Josh,&lt;/P&gt;&lt;P&gt;Thank you so much for your response! I tried using the code you wrote and it ended up making everything "Unknown". I then went back to my old code and applied all of your comments and now it's working great! I definitely learned a lot from your response, and I really appreciate that you took the time to write back as I know I'll have to do more coding in the future.&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Ellie&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 17:56:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147105#M44541</guid>
      <dc:creator>EllieHakariAK</dc:creator>
      <dc:date>2022-02-23T17:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: My arcade code is ending in "Execution Error:Runtime Error:" and I'm not sure why</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147110#M44542</link>
      <description>&lt;P&gt;Well, I'm glad to hear you got it working!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 18:01:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/my-arcade-code-is-ending-in-quot-execution-error/m-p/1147110#M44542</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-23T18:01:35Z</dc:date>
    </item>
  </channel>
</rss>

