Attribute Rule for editor tracking?

411
2
Jump to solution
01-28-2021 10:34 PM
JessicaEdberg
New Contributor II

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

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Regular Contributor

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"]

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Regular Contributor

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"]

Have a great day!
Johannes
JessicaEdberg
New Contributor II

Thank you Johannes for your help

I will try this!

Jessica

0 Kudos