I created an immediate calculation rule in order to update the field value of the child feature (BOULEVARDFLAECHE) with the corresponding field value of the parent feature (BETRIEB). The rule should be triggered when creating the relationship between the objects. The rule is correctly executed when I create the relationship by entering manually the foreign key (FEATURELINK) in the Attributes pane of the child feature. However, the rule is not executed at all when I create the relation by selecting the objects and using “Add Selected To Relationship”. Some information about the data design:
Feature "BETRIEB" (Point)
• Globald (key)
• OERTLICHEKEIT_ID
• …
Feature "BOULEVARDFLAECHE" (Polygon)
• GlobalID
• FEATURELINK (key)
• OERTLICHKEIT_ID (the attribute rule should update this value)
Relationship setting:
• "origin_table": "BETRIEB",
• "destination_table": "BOULEVARDFLAECHE",
• "out_relationship_class": "BETRIEB_BOULEVARDFLAECHE_REL",
• "relationship_type": "COMPOSITE",
• "message_direction": "FORWARD",
• "cardinality": "ONE_TO_MANY",
• "origin_primary_key": "GlobalId",
• "origin_foreign_key": "FEATURELINK"
Attribute Rule:
- Feature: BOULEVARDFLAECHE
Field: OERTLICHKEIT_ID - Triggers: Insert, Update
- Exclude from application evaluation
- Expression:
var orgFeaturelink = $originalFeature.FEATURELINK;
var newFeaturelink = $feature.FEATURELINK;
if (newFeaturelink != orgFeaturelink){
if (IsEmpty(newFeaturelink)) return NULL;
var betrieb = FeatureSetByName($datastore,'STAV_ELICET.STAV_ELICET.BETRIEB',['OERTLICHKEIT_ID', 'GlobalID'],false);
var betrieb_parents = Filter(betrieb, 'GlobalID = @newFeaturelink');
if (Count(betrieb_parents)>0) {
return First(betrieb_parents).OERTLICHKEIT_ID
} else {
return {'errorMessage': 'No referenced parent feature could be found.'}
}
} else {
return $feature.OERTLICHKEIT_ID
}
I hope I was able to explain my problem clearly. Somehow the rule does not realize that the field FEATURELINK has changed when the relation is established by using “add selected to Relationship”.
Background: I need the field OERTLICHKEIT_ID as part of a workaround to the known BUG-000146585 when creating related features in Web AppBuilder and also because of the styling reasons.