Hello! I am trying to output the address of the nearest parcel to automate data entry in a FM form. After modeling an expression from this example (and a few others), I've come up with the below expression. When testing in the arcade expression builder window, it seems to work as it should. When tested as an attribute expression in Map Viewer and added to a popup, it again works flawlessly. The address of the nearest parcel is being displayed in every testing scenario I try.
But, when I use it in the form in the FM mobile app (android and iOS), I get some really odd behavior. It displays an address of a somewhat nearby parcel, but it is never the closest. In addition, I changed the expression to also output the distance, and I am getting unreasonably large distances recorded.
Can someone help me to understand whether or not this is a bug, limitation, or if I am simply doing something wrong in my expression?
Thanks in advance! Here it is:
var searchDistance = 100;
var Parcels = Filter(FeatureSetByName($map,"Parcels",['propertylo']),'propertylo IS NOT NULL');
var closestParcels = Intersects(Parcels, Buffer($feature, searchDistance, "feet"));
var cnt = Count(closestParcels)
Console("Nearby parcels: " + cnt);
var minDistance = 150
var closestParcel;
For (var f in closestParcels){
var parcelDistance = Distance(f, $feature, "feet");
if (parcelDistance < minDistance && !IsEmpty(f.propertylo)) {
closestParcel = f.propertylo;
minDistance = parcelDistance;
}
Console(f.propertylo + ": " + " " + parcelDistance + " ft");
//Return f.propertylo + ": " + " " + parcelDistance
}
Console("Closest: " + closestParcel + " (" +parcelDistance+" ft)");
return closestParcel+" (" +parcelDistance+" ft" + ", closest of " + cnt + " nearby)";
Here it is working properly in Map Viewer popup:

...And improperly in FM mobile (Android):
