Hello All,
I am working on a version of
7. Store info about a nearby feature
from this blog
https://www.esri.com/arcgis-blog/products/field-maps/field-mobility/common-calculated-expressions-for-arcgis-field-maps/
In my version I need to 1) look at multiple layers and 2) get the DomainName as opposed to the stored number value. I have figured out how to get #1 done but I cannot figure out how to get the domain name description and have tried out various scenarios with no luck.
The worst part is I did have this working at one point and removed and re-added the layer the form was built on because it was acting funny, not realizing I would loose the form completely. I just cannot recall how I did it. So if anyone can help me out or point me in the right direction I would really appreciate it.
// If feature doesn't have geometry return null
if (IsEmpty(Geometry($feature))) { return null }
// Get the Possible leaking assets layers
var Mains = FeatureSetByName($map, "WaterDistributionSystem_viewing - Water Main")
var Services = FeatureSetByName($map, "WaterDistributionSystem_viewing - Service")
// Buffer the current location and intersect with Features
var bufferedLocation = Buffer($feature, 30, 'feet')
var candidateMains = Intersects(Mains, bufferedLocation)
var candidateServices = Intersects(Services, bufferedLocation)
// Calculate the distance between the Feature and the current location
// Store the feature and distance as a dictionary and push it into an array
var featuresWithDistances = []
for (var f in candidateMains) {
Push(featuresWithDistances,
{
'distance': Distance($feature, f, 'feet'),
'feature': f
}
)
}
for (var f in candidateServices) {
Push(featuresWithDistances,
{
'distance': Distance($feature, f, 'feet'),
'feature': f
}
)
}
// Sort the candidates of closest features 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 null }
// Return the AssetType
var Facility = DomainName(closestFeatureWithDistance, ['assettype'])
return Facility