Select to view content in your preferred language

Execution Error in Arcade Script

1287
10
08-08-2024 10:27 AM
jacob_ekn
Occasional Contributor

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 @jcarlson linked in another post I had seen. It looks like this:

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);

It won't run in Dashboards and when I put it in Playground it gives me this: Test execution error: Execution error - Logical expression can only be combined with || or &&. Verify test data. 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.

0 Kudos
10 Replies
jacob_ekn
Occasional Contributor

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?

0 Kudos