I am trying to create an indicator that will display a number for both the number of critical infrastructures within an impacted area as well as the number of hospitals within an active evacuation zone. I am receiving an error message saying "Test execution error: Unknown Error. Verify test data." I am having a hard time deciphering what the issue with the code is.
Here is the code for reference:
//Layer source information
var p = portal('https://arcgis.com');
var crit_infra = FeatureSetByPortalItem(portal(p), 'fbb2f2bd73cb4ece92800d3527f9680d', 0, ['*']);
var impacted_area = FILTER(FeatureSetByPortalItem(portal(p), '996efbd08dc8478d9a9315a33ed50bda', 0, ['*']), "activeincid = 'Yes'");
var hcc_mem = FeatureSetByPortalItem(portal(p), '45e9dac6ea264c76818149c4b15717ea', 0, ['*']);
var evac_zone = FILTER(FeatureSetByPortalItem(portal(p), 'b84c5fc156f3420398e21b93c75c00b9', 0, ['*']), "activeincid = 'Yes'");
var final_count = 0;
//Get total count of critical infrastructure intersected by any active impacted areas
for(var i in impacted_area){
var i_count = Count(Intersects(crit_infra, i))
Console(i_count + ' critical infrastructure')
final_count += i_count
Console(final_count)
};
var hcc_count = 0;
//Get total count of hcc members intersected by any active evacuation zones
for (var j in evac_zone){
var j_count = Count(Intersects(hcc_mem, j))
Console(j_count + 'hcc members')
hcc_count += j_count
Console(hcc_count)
};
//Create data schema
var tabl = {
'fields': [
{'name': 'cntType',
'type': 'esriFieldTypeString'},
{'name': 'cntImpCI',
'type': 'esriFieldTypeInteger'},
{'name': 'cntTypes',
'type': 'esriFieldTypeString'},
{'name': 'cntHCC',
'type': 'esriFieldTypeInteger'}],
'geometryType': '',
'features': [],
};
//add data to data schema
tabl.features[0] = {
'attributes':{
'cntType': 'Impacted Infrastructure',
'cntImpCI': final_count,
'cntTypes': 'HCC Members',
'cntHCC': hcc_count,
}
};
//return the featureset
return FeatureSet(Text(tabl));
Solved! Go to Solution.
Not able to test at the moment, but perhaps it is in the portal(p) in the FeatureSetByPortalItem.
Documentation shows:
var features = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),'7b1fb95ab77f40bf8aa09c8b59045449',0,['Name', 'Count'],false);
and you have:
var p = portal('https://arcgis.com');
var crit_infra = FeatureSetByPortalItem(portal(p), 'fbb2f2bd73cb4ece92800d3527f9680d', 0, ['*']);
where you have already set the variable p = portal('https://arcgis.com') then in the FeatureSetByPortalItem it is basically calling portal(portal('https://arcgis.com')) (also, you might need the www in there as well p = portal('https://www.arcgis.com')
Perhaps something like this will work?
var p = Portal('https://www.arcgis.com');
var crit_infra = FeatureSetByPortalItem(p, 'fbb2f2bd73cb4ece92800d3527f9680d', 0, ['*']);
var impacted_area = FILTER(FeatureSetByPortalItem(p, '996efbd08dc8478d9a9315a33ed50bda', 0, ['*']), "activeincid = 'Yes'");
var hcc_mem = FeatureSetByPortalItem(p, '45e9dac6ea264c76818149c4b15717ea', 0, ['*']);
var evac_zone = FILTER(FeatureSetByPortalItem(p, 'b84c5fc156f3420398e21b93c75c00b9', 0, ['*']), "activeincid = 'Yes'");
R
EDIT: just got a chance to test this with Indicator in a Dashboard and get the same error with your code, but not with my modifications, except, doesn't appear to need the www. in the portal URL.
Not able to test at the moment, but perhaps it is in the portal(p) in the FeatureSetByPortalItem.
Documentation shows:
var features = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),'7b1fb95ab77f40bf8aa09c8b59045449',0,['Name', 'Count'],false);
and you have:
var p = portal('https://arcgis.com');
var crit_infra = FeatureSetByPortalItem(portal(p), 'fbb2f2bd73cb4ece92800d3527f9680d', 0, ['*']);
where you have already set the variable p = portal('https://arcgis.com') then in the FeatureSetByPortalItem it is basically calling portal(portal('https://arcgis.com')) (also, you might need the www in there as well p = portal('https://www.arcgis.com')
Perhaps something like this will work?
var p = Portal('https://www.arcgis.com');
var crit_infra = FeatureSetByPortalItem(p, 'fbb2f2bd73cb4ece92800d3527f9680d', 0, ['*']);
var impacted_area = FILTER(FeatureSetByPortalItem(p, '996efbd08dc8478d9a9315a33ed50bda', 0, ['*']), "activeincid = 'Yes'");
var hcc_mem = FeatureSetByPortalItem(p, '45e9dac6ea264c76818149c4b15717ea', 0, ['*']);
var evac_zone = FILTER(FeatureSetByPortalItem(p, 'b84c5fc156f3420398e21b93c75c00b9', 0, ['*']), "activeincid = 'Yes'");
R
EDIT: just got a chance to test this with Indicator in a Dashboard and get the same error with your code, but not with my modifications, except, doesn't appear to need the www. in the portal URL.
This seemed to work, thank you so much!
What Profile are you running this Arcade code in? If this was for a map popup, you'd be better off using FeatureSetByName with the $map global to reference the other layers.
For anything more complex, the Playground is the only way I know to test your expressions. Unfortunately the Playground can only access public data, so you'll either have to hunt down a set of public data that's close enough to your data, or create test data from scratch using the FeatureSet function. For what it's worth, I get the same "Verify test data" error in the playground so there might be a chance everything's working except accessing the data from AGOL, replacing that with test feature sets will help you isolate that issue.
This was for a dashboard indicator. Appreciate the response and I will look into this.