Hi, I am using attribute rule to auto populate an attribute field from a polygon feature to an attribute field in a point feature.
I have suppression repair points with an empty "DPA_AGENCY" Field and a polygon feature that contains the "DPA_AGENCY" information which I want the point "DPA_AGENCY" field to grab from. I've looked up Arcade expressions and I am not even sure I have the right one.
The feature "Suppression_repair_points" the attribute field "DPA_AGENCY"
"Direct_Protection_areas" is the feature I wish to pull info from the "DPA_AGENCY" field
ESRI attribute rule example:
Solved! Go to Solution.
var zones = FeatureSetByName($datastore,"DirectProtectionAreas21",["DPA_GROUP"],true)
var intersectingZones = Intersects(zones, Geometry($feature))
var matchedZone = First(intersectingZones)
return IIf(IsEmpty(matchedZone), null, matchedZone.DPA_GROUP);
You found a quite complicated example 🙂
// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update
// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
// return $feature.DPA_AGENCY
//}
// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "database.dataowner.DirectProtection_areas")
// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)
// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
return null
}
// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY
Thank you! Still receiving an error though.
FeatureSetByName needs the complete name of the feature class.
If you're in a file geodatabase, thats probably just the name of the feature class (DirectProtectionAreas21_2).
If you're in an Enterprise geodatabase, the full name is "DatabaseName.DataownerName.DirectProtectionAreas21_2", where you have to replace DatabaseName and DataownerName.
Browse to the feature class in the catalog to see its full name:
it's a file geodatabase.
So I'd replace: "database.dataowner.DirectProtectionAreas21_2"
with: "DatabaseName.DataownerName.DirectProtectionAreas21_2"
var dpa_fc = FeatureSetByName($datastore, "DirectProtectionAreas21_2")
What is dpa_inter and dpa_fc?
expression valid this time but: ERROR 002717: Invalid Arcade expression, Arcade error: Table not found DirectProtectionAreas21_2, Script line: 12 [DirectProtectionAreas21_2]
Failed to execute (AddAttributeRule).
// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update
// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
// return $feature.DPA_AGENCY
//}
// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "DirectProtectionAreas21_2")
// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)
// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
return null
}
// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY
ERROR: INVALID EXPRESSION ERROR ON LINE 12 Table not found DirectProtectionAreas21_2
// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update
// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
// return $feature.DPA_AGENCY
//}
// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "database.dataowner.DirectProtection_areas")
// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)
// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
return null
}
// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY
var zones = FeatureSetByName($datastore,"DirectProtectionAreas21",["DPA_GROUP"],true)
var intersectingZones = Intersects(zones, Geometry($feature))
var matchedZone = First(intersectingZones)
return IIf(IsEmpty(matchedZone), null, matchedZone.DPA_GROUP);