Hi
I need help to create an attribute rule that can write the value of now() in an attribute field called Attribute_changed when an attribute is changed for an object, and write the value of now() in an attribute field called Geometry_changed if the geometry of an object is changed. I dont think this is possible to specify when I'm useing Editor Tracking in the geodatabas so I want to try use attribute rules. Is it possible to do this with attribute rules and do anybody know how?
I use ArcGIS Pro 2.6.3.
Sincerely Jessica
Solved! Go to Solution.
For now, you'll have to define two rules for that, according to this post , they can be combined into one rule in ArcGIS Pro 2.7.
// Rule: TrackAttributeEdits
// Field: AttributeChanged
// Triggers: Insert, Update
// new entry
if(IsEmpty($originalfeature["AttributeChanged"])) {
return Now()
}
// define the checked attributes as [ [old, new] ]
// do not put things like Shape, AttributeChanged, GeometryChanged or editor tracking fields here!
var monitored_attributes = [
[$originalfeature["Attribute1"], $feature["Attribute1"]],
[$originalfeature["Attribute2"], $feature["Attribute2"]],
]
// check those attributes, return Now() at the first changed one
for(var a in monitored_attributes) {
var old_att = monitored_attributes[a][0]
var new_att = monitored_attributes[a][1]
if(old_att != new_att) {
return Now()
}
}
// nothing changed
return $feature["AttributeChanged"]
// Rule: TrackGeometryEdits
// Field: GeometryChanged
// Triggers: Insert, Update
// new entry
if(IsEmpty(Geometry($originalfeature))) {
return Now()
}
// compare geometries
var old_geo = Geometry($originalfeature)
var new_geo = Geometry($feature)
if(!Equals(old_geo, new_geo)) {
return Now()
}
// nothing changed
return $feature["GeometryChanged"]
For now, you'll have to define two rules for that, according to this post , they can be combined into one rule in ArcGIS Pro 2.7.
// Rule: TrackAttributeEdits
// Field: AttributeChanged
// Triggers: Insert, Update
// new entry
if(IsEmpty($originalfeature["AttributeChanged"])) {
return Now()
}
// define the checked attributes as [ [old, new] ]
// do not put things like Shape, AttributeChanged, GeometryChanged or editor tracking fields here!
var monitored_attributes = [
[$originalfeature["Attribute1"], $feature["Attribute1"]],
[$originalfeature["Attribute2"], $feature["Attribute2"]],
]
// check those attributes, return Now() at the first changed one
for(var a in monitored_attributes) {
var old_att = monitored_attributes[a][0]
var new_att = monitored_attributes[a][1]
if(old_att != new_att) {
return Now()
}
}
// nothing changed
return $feature["AttributeChanged"]
// Rule: TrackGeometryEdits
// Field: GeometryChanged
// Triggers: Insert, Update
// new entry
if(IsEmpty(Geometry($originalfeature))) {
return Now()
}
// compare geometries
var old_geo = Geometry($originalfeature)
var new_geo = Geometry($feature)
if(!Equals(old_geo, new_geo)) {
return Now()
}
// nothing changed
return $feature["GeometryChanged"]
Thank you Johannes for your help
I will try this!
Jessica