I have a point feature class (parent) and a related table (child) in an Enterprise Geodatabase (v 11.4). They have a user-defined relationship class. Upon child record creation, I would like a field in the child table to populate based on 1 of 2 parent fields using conditionality. If Parent Field 1 contains a value, child field will populate from Parent Field 1. If Parent Field 1 is empty, the child field will populate from Parent Field 2.
The attribute rule below is set to the child field to-be-populated. It passes validation and is able to be saved as an attribute rule. However, upon attempting to add a record to the child table, an error says "invalid column value [parent field 1 field name]".
If anyone can tweak this or provide a better code to accomplish my goal, I'd appreciate it!
// Define the relationship name between the child and parent feature classes/tables
var Relationship = "RELATIONSHIP CLASS NAME"; // Replace with your actual relationship name
// Get the related parent feature(s)
var RelatedParentFeatures = FeatureSetByRelationshipName($feature, Relationship);
// Get the first related parent feature (assuming a one-to-one or one-to-many relationship where you want the first related parent)
var ParentFeature = First(RelatedParentFeatures);
// Check if a parent feature exists and if the specific parent field is empty
if (IsEmpty(ParentFeature) || IsEmpty(ParentFeature.PARENT FIELD 1)) {
// If the parent feature or the parent field is empty, populate the child field with a default value or null
return "PARENT FIELD 2"
} else {
// If the parent field has a value, populate the child field with the parent's field value
return ParentFeature.PARENT FIELD 1;
}
@JohannesLindner