Hello!
I am having some trouble getting an Arcade Expression to work and am hoping for some help! I have developed a Web App using ArcGIS Web Maps/Dashboard and Survey123. This application allows our local area hospitals to update themselves and their Diversion Status. The hospitals can put themselves on Diversion status of colors such as "Green" "Yellow" "Red" to indicate whether they can accept patients via ambulance or not. Only one hospital can be on "Red" at any given time.
I am trying to write an expression to intersect the hospitals layer which is a hosted view of the current statuses and determine whether any of the hospitals currently have a status of Red or not. If they do it can return which hospital is "Red" and if none then "None Red". Once I can get that expression working I can pass that off to Survey123 to limit the answers the other hospitals can select from to remove red. I have tried the below expression with numerous modifications but keep getting the error "h.charAt is not a function". Can someone help me figure out what I am doing wrong?
var bufferDistance = 25; // buffer distance in miles
var bufferGeometry = Buffer($feature, bufferDistance, 'miles');
var intersectedFeatures = Intersects(bufferGeometry, FeatureSetByName($map, 'Current_Hospital_Statuses'));
var filteredFeatures = Filter(intersectedFeatures, $feature.diversionstatus == 'red');
if (Count(filteredFeatures) > 0) {
var matchingFeature = First(filteredFeatures); // get first matching feature
var name = matchingFeature['hospitalname']; // get name attribute value
return name; // return name value
}
else {
return 'None Red'; // return error message if no matches found
}
Solved! Go to Solution.
I think the error is in your Filter. Try this instead
var filteredFeatures = Filter(intersectedFeatures, "diversionstatus = 'red'");
I think the error is in your Filter. Try this instead
var filteredFeatures = Filter(intersectedFeatures, "diversionstatus = 'red'");
You sir are a genius! That worked perfectly, thank you so much for taking the time to help me! I get somewhat confused with Arcade and tried to have ChatGPT help me and it just must not know the syntax. Thank you again for the help!