Hello Esri community,
I hope you are all doing well. I recently encountered a bug while working with an attribute rule on a point feature class, and I wanted to reach out to the forum to see if anyone else has experienced a similar issue or if I am potentially making a mistake that I haven't been able to identify yet.
The purpose of my script is to add vertexes to a line feature when it intersects with specific point features. To assist in debugging and determining if the script is triggered during update processes, I inserted an error message to check for its execution. To my surprise, I discovered that the script is not triggered when I attempt to move an existing point feature around.
Upon further investigation, I observed the following behavior, which might help in diagnosing the issue:
I'm having difficulty pinpointing the exact cause of this behavior and determining if I have made a mistake in my script or if this really is an esri bug. I would greatly appreciate any assistance or insights that you can provide.
Thanks and kind regards,
Stefan
This was the script + return error i used:
// This was added to check if the rule is even triggerd, with this statement i found the potential bug.
return {"errorMessage": "triggered2"};
// get intersecting line features
var lines = FeaturesetByName($datastore, "PipelineLine", ["GlobalID"], true);
var i_lines = Intersects(lines, $feature);
if (isEmpty(i_lines)) {
return {"errorMessage": "didnt find intersecting line"};
}
// create update variable
var updates = [];
// get distances from start and end point
for (var line in i_lines) {
return {"errorMessage": "got line geo" + Text(Geometry(line))};
var line_geo = Geometry(line);
var point_geo = Geometry($feature);
var d_start = Distance(point_geo, line_geo.paths[0][0]);
var d_end = Distance(point_geo, line_geo.paths[-1][-1]);
// get the new point coordinates: x/y from the closest line end point, z from the point
var i = IIf(d_start < d_end, 0, -1);
var v = [line_geo.paths[i][i].x, line_geo.paths[i][i].y, point_geo.z, null];
for (var k = 0; k < Count(line_geo.paths[i]); k++) {
if (line_geo.paths[i][k].x == v[0] && line_geo.paths[i][k].y == v[1] && line_geo.paths[i][k].z == v[2]) {
return;
}
}
// add vertex at start or end of line
var new_line_geo = Dictionary(Text(line_geo));
var j = IIf(i == 0, 0, Count(new_line_geo.paths[0]));
Insert(new_line_geo.paths[0], j, v);
var update = {
"globalID": line.GlobalID,
"geometry": Polyline(new_line_geo)
};
Push(updates, update);
}
return {
edit: [{
"className": "PipelineLine",
"updates": updates
}]
};