Attribute rule not triggered when creating a related feature in ArcGIS Pro

1255
4
02-28-2022 06:24 AM
TWickiSLU
New Contributor III

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.

 

4 Replies
MartinKrál
Esri Contributor

Hello @TWickiSLU 

It seems to me,  that we are in same trouble with "Add Selected To Relationship" and atrribute rule  as you described here .

Please, did you found out what was problem in your case, or was there any solution to it?

Thank you

0 Kudos
TWickiSLU
New Contributor III

Hello

No, unfortunately I did not find a satisfactory solution. ESRI support gave me the following answer:

«Problem was: attribute rules were not triggered by 'add selected to relationship' (in the attribute pane when editing). 'add selected to relationship' cannot be used to trigger ‘immediate attribute calculation rules'. Performing this action does not directly update the feature class, but only changes the reference of the ID set in the relationship. The relationship class is edited by 'add selected to relationship' and not directly the target class, here the updated value is only reflected» (translated from german to english)

In my case, I changed the workflow in the following way: Instead of using "add selected to relationship", the user must enter the «OERTLICHEKEIT_ID» in both the parent and child feature. After saving the child feature, a calculation rule is executed that fills in the FETURELINK to the parent feature with the same «OERTLICHEKEIT_ID» (see video). Entering the value («OERTLICHEKEIT_ID») directly in the target feature (child feature) allows to trigger immediate attribute rules. However, it’s not a very nice solution.

Kind regards

0 Kudos
MartinKrál
Esri Contributor

Thank  you very much  @TWickiSLU for your quick response.

Very likely we will end up applying same "solution".

Regards

0 Kudos
TWickiSLU
New Contributor III

Please inform me if you find another solution or workaround 🙂

Regrads

0 Kudos