Hello All,
I have created some code to count how many features result from their inclusion when the NearMe widget is run in ExB. When the arcade loads it see all features so case 1) There is more than 0 features. When I run the NearMe widget case 2) determines if there is more than 0 and fails. all good.
My problem is trying to get it to report case 3) when there are 0 features in the NearMe polygon so I can report out "0 features are in the area". What seems to happen is that it still sees All the features as nothing is actually selected when 0 are found. makes sense, I just need to account for that. Here is my script:
// Arcade expression to count the number of selected features in a NearMe promity selection
// Define the feature layer
var layer = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '#######################', 0, ['*']);
// Retrieve the selected features
// var selectedFeatures = Filter(layer, "OBJECTID IN <a href="https://community.esri.com/t5/user/viewprofilepage/user-id/577603">@Selection</a>");
// Count the number of selected features
var cntFeats = Count($layer)
if (cntFeats > 0) {
return "There are existing fetures in the NearMe area (" + cntFeats + ") so FAIL";
}
else {
return "There are no existing fetures in the NearMe area so PASS";
} Perhaps someone has an idea.
Thanks,
GRMapper