Hi,
I was wondering if it's possible to auto populate the coordinates of a created point feature into an existing row rather than a new row.
Thanks!
Solved! Go to Solution.
Something like this could do what you want:
// Calculation Attribute Rule on your point FC
// Field: empty
// Triggers: Insert
// Exclude from application evaluation
// get the rows that will be updated
var key = $feature.KeyField
var table = FeatureSetByName($datastore, "Database.Dataowner.TableYouWantToEdit", ["GlobalID", "KeyField"], false)
var rows = Filter(table, "KeyField = @key")
// create and fill the update array
var lat_long_attributes = {"LAT": Geometry($feature).y, "LONG": Geometry($feature).x}
var updates = []
for(var row in rows) {
Push(updates, {"globalID": row.GlobalID, "attributes": lat_long_attributes}
}
// tell ArcGIS to edit the table
return {
"edit" [{
"className": "Database.Dataowner.TableYouWantToEdit",
"updates": updates
}]
}
The workflow for this would be
So you want to do something like this?
This could be kinda possible (you'd end up with a feature without geometry, so you wouldn't see it on the map). But, questions:
Thanks for your reply,
So you want to do something like this?
I want to add a new point feature that populates the coordinates into empty lat/long fields in an existing row in my table.
I want an editor to add coordinates to places that have wrong attribute info so the data can be fixed downstream using the updated coordinates. I want as little manual editing done as possible so I thought this could be a good solution (no copy/pasting correct coordinates into lat/long fields). We don’t edit existing data, just update new corresponding fields.
Hope I answered all your questions!
Something like this could do what you want:
// Calculation Attribute Rule on your point FC
// Field: empty
// Triggers: Insert
// Exclude from application evaluation
// get the rows that will be updated
var key = $feature.KeyField
var table = FeatureSetByName($datastore, "Database.Dataowner.TableYouWantToEdit", ["GlobalID", "KeyField"], false)
var rows = Filter(table, "KeyField = @key")
// create and fill the update array
var lat_long_attributes = {"LAT": Geometry($feature).y, "LONG": Geometry($feature).x}
var updates = []
for(var row in rows) {
Push(updates, {"globalID": row.GlobalID, "attributes": lat_long_attributes}
}
// tell ArcGIS to edit the table
return {
"edit" [{
"className": "Database.Dataowner.TableYouWantToEdit",
"updates": updates
}]
}
The workflow for this would be
Thanks for your help, I really appreciate it!
Thanks again!
Are you sure that you're creating it on the right feature class? This behavior sounds like you create the rule on the class you want to update.
Thanks again!
Yeah, as I thought.
You're adding the rule to the feature class you want to update. That means that you create a point, and then the rule triggers and edits a point in the same class.
The rule is meant to be created on a different point feature class that you use to edit the "real" feature class.
Here is a filegdb example which a calculation rule updates the X and Y fields with the point's geometry coordinates on insert and update. We assign the field as empty so we can update multiple fields in one shot. The rule is simple
var g = Geometry($feature);
var x = g.x;
var y = g.y;
return {
"result": {
"attributes": {
"x": x,
"y": y
}
}
}
the rule