Hello Community,
I am trying to determine why this arcade expression runs during testing, but then when I click "done" and go back to the "Select a layer" page to select the expression to use in a bar chart the data expression text is grayed out with an alert saying "Unable to execute Arcade script".
I've included my script below for reference, I would appreciate any assistance or explanation why this isn;t working as intended.
// sets portal url
// assign Crash Dataset variables
var crashDatasetID = '50b2634c8c9443f58cd004f1138ef7ea';var crashLayerID = 0;
// assign FeatureSet variables
var crashFs = FeatureSetByPortalItem(cobportal, crashDatasetID, crashLayerID, ['number_dead', 'gis_incapacitating'], true);
// Initialize counters
var totalDeaths = 0;var totalInjuries = 0;
// Iterate through the FeatureSet and calculate totals
for (var crash in crashFs) {
if (IsEmpty(crash.number_dead) == false && crash.number_dead > 0) {
totalDeaths += crash.number_dead;
}
if (IsEmpty(crash.gis_incapacitating) == false && crash.gis_incapacitating == 'Yes') {
totalInjuries += 1;
}
}
// Return the results as an array
return [totalDeaths, totalInjuries];