<?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: Execution Error in Arcade Script in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516986#M7189</link>
    <description>&lt;P&gt;Is it possible that the size of my point dataset is too large and that could be causing an error? The point feature class has around 150k points.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2024 21:38:36 GMT</pubDate>
    <dc:creator>jacob_ekn</dc:creator>
    <dc:date>2024-08-08T21:38:36Z</dc:date>
    <item>
      <title>Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516815#M7179</link>
      <description>&lt;P&gt;Hello, I'm writing a script for a Dashboard where I have lots of points and want the user to be able to export data on points that land in fire zones or weather events. The script creates a list of the polygons each point is within (under the condition that it's within a fire zone or weather event in the first place) and adds them as one string to a new field. I made sort of a variation of a script written by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;linked in another post I had seen. It looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com");

var fire_poly = FeatureSetByPortalItem(
    portal,
    'd957997ccee7408287a963600a77f61f',
    1,
    [
        'IncidentName'
    ],
    true
);

var weather_poly = FeatureSetByPortalItem(
    portal,
    'a6134ae01aad44c499d12feec782b386',
    6,
    [
        'Event',
        'Severity'
    ],
    true
);

var pt_fs = FeatureSetByPortalItem(
    portal,
    'item_id_removed_for_security',
    0,
    [
        'SAP_EQUIP_',
        'SAP_STRUCT',
        'TLINE_NM',
        'SAP_FUNC_L',
        'GIS_LAT',
        'GIS_LONG'
    ],
    true
);

var features = [];
var feat;

for (var pnt in pt_fs) {
    var in_fire = [];
    var in_event = [];

    if (Within(pnt, fire_poly) || Within(pnt, weather_poly)) {
        for (var poly in fire_poly) {
            if (Within(pnt, poly)) {
                Push(in_fire, poly['IncidentName']);
            }
        }

        for (var poly in weather_poly) {
            if (Within(pnt, poly)) {
                Push(in_event, poly['Severity'] + " " + poly['Event'])
            }
        }

        feat = {
            'attributes': {
                'SAP_EQUIP': pnt['SAP_EQUIP_'],
                'STRUCT_NO': pnt['SAP_STRUCT'],
                'TLINE_NM': pnt['TLINE_NM'],
                'FUNC_LOC': pnt['SAP_FUNC_L'],
                'GIS_LAT': pnt['GIS_LAT'],
                'GIS_LONG': pnt['GIS_LONG'],
                'fire': IIf(IsEmpty(First(in_fire)), "N/A", Concatenate(in_fire, ", ")),
                'weather_event': IIf(IsEmpty(First(in_event)), "N/A", Concatenate(in_event, ", "))
            }
        };

        Push(features, feat);
    }
}

var out_dict = {
    'fields': [
        {'name': 'SAP_EQUIP', 'alias': 'SAP Equipment ID', 'type': 'esriFieldTypeString'},
        {'name': 'STRUCT_NO', 'alias': 'Structure Number', 'type': 'esriFieldTypeString'},
        {'name': 'TLINE_NM', 'alias': 'Transmission Line', 'type': 'esriFieldTypeString'},
        {'name': 'FUNC_LOC', 'alias': 'SAP Functional Location', 'type': 'esriFieldTypeString'},
        {'name': 'GIS_LAT', 'alias': 'Latitude', 'type': 'esriFieldTypeDouble'},
        {'name': 'GIS_LONG', 'alias': 'Longitude', 'type': 'esriFieldTypeDouble'},
        {'name': 'fire', 'alias': 'Name of Fire', 'type': 'esriFieldTypeString'},
        {'name': 'weather_event', 'alias': 'Weather Event', 'type': 'esriFieldTypeString'}
    ],
    'geometryType': '',
    'features': features
};

return FeatureSet(out_dict);&lt;/LI-CODE&gt;&lt;P&gt;It won't run in Dashboards and when I put it in Playground it gives me this:&amp;nbsp;&lt;STRONG&gt;Test execution error: Execution error - Logical expression can only be combined with || or &amp;amp;&amp;amp;. Verify test data.&amp;nbsp;&lt;/STRONG&gt;Since Playground doesn't tell me what line the error is from I'm not really sure what the issue is or what to try to change. Hoping it's just something I'm overlooking.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 17:27:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516815#M7179</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T17:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516866#M7180</link>
      <description>&lt;P&gt;Your problem is on line 46 (as well as 48 and 54). Within returns a FeatureSet, which can't be directly evaluated in an if statement. You have to return some sort of boolean, such as&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (Count(Within(pnt, fire_poly)) &amp;gt; 0 || Count(Within(pnt, weather_poly) &amp;gt; 0)) {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 18:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516866#M7180</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-08-08T18:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516893#M7181</link>
      <description>&lt;P&gt;Thank you! It's interesting because the function reference says that Within returns a boolean, but this got rid of that error. However, I'm now getting an "unknown error" so I guess my struggle continues for now.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 19:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516893#M7181</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T19:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516918#M7183</link>
      <description>&lt;P&gt;I was looking at the FeatureSet Within instead of the Feature Within. Still, when I ran a test on the Feature Within, it returns a FeatureSet.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_1997644.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111985iF4D5E030E2E9AC83/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_1997644.png" alt="Snag_1997644.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I misplaced a parenthesis in the second Count. Try this instead.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (Count(Within(pnt, fire_poly)) &amp;gt; 0 || Count(Within(pnt, weather_poly)) &amp;gt; 0) {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 19:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516918#M7183</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-08-08T19:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516923#M7184</link>
      <description>&lt;P&gt;Yes I changed it to that, but there's still an unknown error, I'm guessing it's probably a different issue somewhere else in the script.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 19:58:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516923#M7184</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T19:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516924#M7185</link>
      <description>&lt;P&gt;(By the way, there's a missing semicolon on line 55 that I already fixed but I don't seem to be able to edit my post)&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 20:02:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516924#M7185</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T20:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516942#M7186</link>
      <description>&lt;P&gt;You can use &lt;A href="https://developers.arcgis.com/arcade/function-reference/debugging_functions/#console" target="_self"&gt;Console&lt;/A&gt; to test out where the script is breaking. If I have a problem with the script, I sprinkle them throughout to find the problem line.&lt;/P&gt;&lt;P&gt;As it turns out, I was incorrect for lines 48 and 54. I was mixing up the Withins. The one on line 46 is a FeatureSet Within and doesn't return a Boolean, while the other two are Geometry Withins which do return a Boolean.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    for (var poly in fire_poly) {
      if (Within(pnt, poly)) {
        Push(in_fire, poly["IncidentName"]);
      }
    }

    for (var poly in weather_poly) {
      if (Within(pnt, poly)) {
        Push(in_event, poly["Severity"] + " " + poly["Event"]);
      }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 20:36:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516942#M7186</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-08-08T20:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516960#M7187</link>
      <description>&lt;LI-CODE lang="javascript"&gt;for (var pnt in pt_fs) {
    var in_fire = [];
    var in_event = [];
    var has_fire = Count(Within(pnt, fire_poly)) &amp;gt; 0;
    var has_weather = Count(Within(pnt, weather_poly)) &amp;gt; 0;
    Console("Outer for loop iterating.");

    if (has_fire || has_weather) {
        Console("First conditional passed.");&lt;/LI-CODE&gt;&lt;P&gt;I gave this a try and got a good number of iterations on the outer loop (I'm guessing on points that weren't within any polygons) then eventually got the unknown error again.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 20:56:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516960#M7187</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T20:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516965#M7188</link>
      <description>&lt;P&gt;You'd have to use this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for (var pnt in pt_fs) {
    var in_fire = [];
    var in_event = [];
    var has_fire = Within(pnt, fire_poly);
    var has_weather = Within(pnt, weather_poly);
    Console("Outer for loop iterating.");

    if (has_fire || has_weather) {
        Console("First conditional passed.");&lt;/LI-CODE&gt;&lt;P&gt;I was testing on some public data and got it to work&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com");

var fire_poly = FeatureSetByPortalItem(
  portal,
  "d957997ccee7408287a963600a77f61f",
  1,
  ["IncidentName"],
  true
);

var weather_poly = FeatureSetByPortalItem(
  portal,
  "a6134ae01aad44c499d12feec782b386",
  6,
  ["Event", "Severity"],
  true
);

var pt_fs = Top(FeatureSetByPortalItem(
  portal,
  "9e2f2b544c954fda9cd13b7f3e6eebce",
  0,
  ["*"],
  true
), 80);

var features = [];
var feat;
for (var pnt in pt_fs) {
  var in_fire = [];
  var in_event = [];
  if (Count(Within(pnt, fire_poly)) &amp;gt; 0 || Count(Within(pnt, weather_poly)) &amp;gt; 0) {
    
    for (var poly in fire_poly) {
      if (Within(pnt, poly)) {
        Push(in_fire, poly["IncidentName"]);
      }
    }

    for (var poly in weather_poly) {
      if (Within(pnt, poly)) {
        Push(in_event, poly["Severity"] + " " + poly["Event"]);
      }
    }
console(pnt)
    feat = {
      attributes:
        {
          SAP_EQUIP: pnt["place"],
          fire: IIf(IsEmpty(First(in_fire)), "N/A", Concatenate(in_fire, ", ")),
          weather_event:
            IIf(IsEmpty(First(in_event)), "N/A", Concatenate(in_event, ", "))
        }
    };

    Push(features, feat);
  }
}

var out_dict = {
  fields: [
    { name: "SAP_EQUIP", alias: "SAP Equipment ID", type: "esriFieldTypeString" },
    { name: "fire", alias: "Name of Fire", type: "esriFieldTypeString" },
    {
      name: "weather_event",
      alias: "Weather Event",
      type: "esriFieldTypeString"
    }
  ],
  geometryType: "",
  features: features
};

return FeatureSet(out_dict);&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_1e40a1f.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111994i08DBAE8D4B15AE75/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_1e40a1f.png" alt="Snag_1e40a1f.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 21:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516965#M7188</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-08-08T21:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516986#M7189</link>
      <description>&lt;P&gt;Is it possible that the size of my point dataset is too large and that could be causing an error? The point feature class has around 150k points.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 21:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1516986#M7189</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T21:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Execution Error in Arcade Script</title>
      <link>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1517024#M7190</link>
      <description>&lt;P&gt;Hey so I think the issue is the number of points as I was able to get it to work with a smaller subset of the data I'm using. Is there not really a solution to this now or does my script just need to be optimized somehow?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 22:39:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/execution-error-in-arcade-script/m-p/1517024#M7190</guid>
      <dc:creator>jacob_ekn</dc:creator>
      <dc:date>2024-08-08T22:39:43Z</dc:date>
    </item>
  </channel>
</rss>

