Hello, I am looking for some tips to complete Arcade expression for calculation rule of Attribute Rules that does as follows:
1. Create a buffer around a created point feature
2. Update a buffer location accordingly when a point feature's location is updated
3. If there is an intersect between a point feature and another polygon feature (say "Park"), get attribute values from another polygon class to populate fields of a point featureclass
Problems:
1. When a new point is created, a buffer is not created and also fields not populated with extracted values
2. When existing point is moved, Buffer is updated its location based on the updated point and also fields are populated successfully with the extracted values. But an additional buffer feature is also created in the buffer polygon feature class.
my code is below:
var bufferedGeometry = buffer($feature,500)
var globalId = $feature.globalid
var fs = FeatureSetbyName($datastore, "PolygonClass")
var bf = filter(fs, "PointGuid = @globalId")
if (count(bf) == 0) return $feature.NAME;
var bufferedFeature = first(bf)
var fsPark = FeatureSetByName($datastore, "Park", ["*"])
var fsParkIntersect = Intersects(fsPark, Geometry($feature))
var ParkAtt = First(fsParkIntersect)
if (ParkAtt == null)
return {"errorMessage": "Point must be created in Park."}
else
return {
"result": {
"attributes" : {
"NAME" : "Point" + ParkAtt.NAME,
"ParkNAME" : ParkAtt.NAME,
"ParkID" : ParkAtt.ParkID
}
},
"edit": [
{
"className" : "PolygonClass",
"adds" : [
{
"attributes": {
"NAME": $feature.NAME,
"PointGuid": $feature.GlobalID
},
"geometry": bufferedGeometry
}
],
"updates" : [
{
"GlobalID" : bufferedFeature.globalId,
"NAME": $feature.NAME,
"geometry": bufferedGeometry
}
]
}
]
}
I created the above code based on the code found here https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules/
Thanks in advance for your help.