Select to view content in your preferred language

Attribute Rule to pass a value from parent to child

7519
21
Jump to solution
12-08-2021 07:59 AM
dcamara924
Emerging Contributor

Hello. I'm attempting to pass a value from a parent feature to a related table using an Attribute Rule. The idea being that when a new related record is created it automatically populates this field based on its corresponding parent value. This seems like it should be easy to do but the arcade expression is proving challenging for my beginner level of arcade experience. The fields are both called "GPMDesign" and are both "Long" field types.  I'm running ArcGIS Pro 2.7.1 and Enterprise 10.8.1. Thank you!

0 Kudos
21 Replies
JohannesLindner
MVP Frequent Contributor

It looks as if the rule doesn't find the parent feature and aborts in line 6. You could test that theory by returning a default value if that happens. 

Also, you're getting the related features in line 1 and then filter these features in lines 2&3. I used FeaturesetByName in my example and had to use the filter to get the related features. You use FeaturesetByRelationshipName, so the parent_fs already contains only the related features, the filter doesn't do anything.

var parent_fs = FeatureSetByRelationshipName($feature, "SAN_Manhole_To_SAN_Manhole_Inspection");

var manhole = First(parent_fs);
if (manhole == null) {return {"result": {"attributes": {"LOCATIONDESCRIPTION": "No parent feature found!"}}}};

var atts = 
{
    "LOCATIONDESCRIPTION": manhole.LOCATIONDESCRIPTION,
    "SETTLEMENTAREA": manhole.SETTLEMENTAREA,
    "LOCALMUNICIPALITY": manhole.LOCALMUNICIPALITY,
    "DEPOTAREA": manhole.DEPOTAREA
};

return {"result": {"attributes": atts}};

 


Have a great day!
Johannes
BrianBulla
Honored Contributor

Thanks....yes, I tried both with FeaturesetByName and FeaturesetByRelationshipName, but get the same results either way.

I'll add some console messages and try to figure this out.

Thanks for your help!

0 Kudos