Select to view content in your preferred language

Arcade Syntax Error: Text execution error: Unknown Error. Verify test Data

201
1
05-21-2024 03:14 PM
DanielDuncan
New Contributor II

I would appreciate some help with my Arcade code. It keeps on saying "Text execution error: Unknown Error. Verify test Data"
I am attempting to add the sums of the values in two fields in my underlying layer, and once I get those two sums, add return the feature set with the calculated value. I am not sure where the problem even is as nothing is highlighted for me to even address. I appreciate whoever helps out with this

 

 

var p = Portal('https://GOJ.maps.arcgis.com/');

var fs = FeatureSetByPortalItem(p, '58bc1181751d4ea980c3f6bde0eaa323', 1, ['BallotsCastC1', 'BallotsCastC2', 'BoxesCounted'], false);
var s = Schema(fs);
Push(s.fields, {'name':'BallotsTotal', 'alias': 'Ballots Total', 'type': 'esriFieldTypeDouble'})

var returnFS = {
    fields: s.fields,
    geometryType: '',
    features: []
};

var sumBallotsCastC1 = 0;
var sumBallotsCastC2 = 0;

for (var r in s) {
    sumBallotsCastC1 += r.BallotsCastC1;
    sumBallotsCastC2 += r.BallotsCastC2;
    
}

var ballotsTotal = sumBallotsCastC1 + sumBallotsCastC2;



var featureAttributes = {
    BallotsCastC1: sumBallotsCastC1,
    BallotsCastC2: sumBallotsCastC2,
    BallotsTotal: ballotsTotal
};

Push(returnFS.features, {'attributes': featureAttributes});

return FeatureSet(Text(returnFS));

 

 

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

It's hard to test this on your private data, but one thing I see is in line 16, you're looping through the Schema, not the FeatureSet.

Debugging a script can be made easier by using Console messages at certain points to see where the script is crashing and checking in the variables you're using a returning what you're expecting.

0 Kudos