Hello
I have this code which is from Esri blog and I am trying to return exact address values from parcel data (MapPLUTO) but I don't want to retune Null values instead I want return Not Detected for Address field for cases which code can find address
// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return "Not Detected"}
// Get the parcels layer
var parcels = FeatureSetByName($map,"MapPLUTO")
// Buffer the current location and intersect with parcels
var bufferedLocation = Buffer($feature,50, 'feet')
var candidateParcels = Intersects(parcels, bufferedLocation)
// Calculate the distance between the parcel and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateParcels) {
Push(featuresWithDistances,
{
'distance': Distance($feature, f, 'feet'),
'feature': f
}
)
}
// Sort the candidate parcels by distance using a custom function
function sortByDistance(a, b) {
return a['distance'] - b['distance']
}
var sorted = Sort(featuresWithDistances, sortByDistance)
// Get the closest feature
var closestFeatureWithDistance = First(sorted)
// If there was no feature, return null
if (IsEmpty(closestFeatureWithDistance)) { return "Not Detected"}
// Return the address
return `${closestFeatureWithDistance['feature']['Address']}`
