I am trying to generate a centroid in a feature layer when a propertyID is added to a polygon feature layer. I have it set to update.
Here is what I have so far:
// Check if the PropertyID is entered (not null)
if ($feature.PropertyID != null) {
// Calculate the centroid of the polygon (point location)
var centroidPoint = centroid($feature);
// Ensure the centroid was successfully calculated
if (centroidPoint != null) {
return {
// Define the edit operation to create the point in the other feature class
"edit": [
{
// Specify the target feature class where the point will be created
"className": "Test_Points", // Ensure this matches the name of the point feature class
// Define the adds operation for inserting a new point feature
"adds": [
{
// Specify the attributes for the new point feature
"attributes": {
"PropertyID": $feature.PropertyID, // Use the PropertyID from the polygon
"PropertyName": $feature.PropertyName // Use other attributes if necessary
},
// Use the calculated centroid geometry for the new point
"geometry": centroidPoint
}
]
}
]
};
} else {
// Return an error if the centroid could not be calculated
return {
"error": "Centroid calculation failed."
};
}
} else {
// No PropertyID entered, so no point is created
return {};
}
I keep getting this error message, only when the PropertyID is added does this message appear.:
Update table row failed.
The Geometry has no Z values [
Rule name: New Point,
Triggering event: Update,
Class name: Test_Polygons,
GlobalID: {8036C9B8-FA66-4018-AD39-79E075D7C1EA}]The Geometry has no Z values