Select to view content in your preferred language

Attribute Rule to transfer a value from a parent feature class to a related child table field

09-08-2023 09:58 AM
Occasional Contributor
I have a Parent Feature Class in ArcGIS Pro called "Structure" that has a field called StructureType that has subtypes of Rock Sill, Coir Log, Oyster Structure, etc.  I have a related child table called "StructureInspection" to collect inspection data on these structures. One structure will have many inspections.  


The feature class and the StructureInspection table are related by GlobalID and GUID fields.

 The StructureInspection table holds all inspection fields for all Structure types. Each StructureType has different inspection fields associated with it. I need the StructureType field in the StructureInspection table populated with the value of the StructureType of the Parent feature class to be able to control what fields are visible on the inspection form in Field Maps for the specific structuretype.  I don't want users to have to enter in the structure type every time for a structure inspection.  The StructureType is designated with the feature when it is created, and the structure inspection table is related to the feature (through a relationship class called Structure_StructureInspection).
The datatype of the StructureType field in the parent feature class is Short (Numeric) because it has subtypes.
The datatype of the StructureType field in the StructureInspection table is Short to be compatible.
I want the StructureType value of the parent feature class to automatically populate in the StructureType field of the related child StructureInspection table when a new record is created in the StructureInspection table.
I have tried doing this using an Attribute Rule in ArcGIS Pro:  
      Using the Calculation Rule
      I did not select a field; I want this to trigger with any field.
      I have it triggering on Insert, when a record is created
The Arcade expression used:
var relTable = "StructureInspection"
var GUID = $feature.StrucInsp_GUID
var Structure = FeatureSetByName($datastore, "Structure", ["GlobalID", "StructureType"], false);
var related_inspections = Filter(Structure, "GlobalID = @GUID");
var structureTypes = [];
for (var i in related_inspections) {
    structureTypes[i] = related_inspections[i]["StructureType"];
return structureTypes;
I get no errors with the Attribute Rule, but the StructureType does not populate when a new record is created in the StructureInspection table.
I would love if someone could help solve why this is not working!  Thank you!!!  



0 Kudos
2 Replies
MVP Frequent Contributor
  • you actually do want to assign this rule to a field. The field parameter controls in which field the output of the expression is stored. An edit to any field will trigger the rule.
  • your variable names are very misleading. related_inspections is actually the Structure feature class!
  • if you have a relationship class, you can use FeaturesetByRelationshipName() instead of filtering the Featureset yourself
  • your for loop treats the Featureset like an array. For arrays, the loop counter (i) is an integer. For Featuresets, it is the current feature. So your indexing doesn't work, because i is a Feature, not a number.
  • You're trying to return an Array, but the rule expects a single value.


Something like this should work:

// Calculation Attribute Rule on hte inspection table
// field: StructureType
// triggers: Insert, Update
    // depending on how you create your inspection record, it won't be able to find the parent feature on Insert, so you should also trigger on Update

// optional: abort if there is already a value in the field
if(!IsEmpty($feature.StructureType)) { return $feature.StructureType }

// get the parent feature
var parent = First(FeaturesetByRelationshipName($feature, "Structure_StructureInspection"))

// if a parent feature was found, return its StructureType, else return a default value
return IIf(parent == null, "no parent found", parent.StructureType)

Have a great day!
Occasional Contributor

Hi Johannes!  Thank you for taking the time to respond to my question, I greatly appreciate it! Based on your suggestions, I selected the StructureType field from the StructureInspection table in the Field box for the Attribute Rule. This is where I want the output of the expression to be stored (the value of the StructureType field). I added your code in the expression box.  Added the trigger update so now have Insert and Update triggers. I checked exclude from application evaluation. I saved it. The attribute rule turned green. I published my layer. Created a web map with forms in ArcGIS Online.  Opened my webmap in Field Map App. I created a structure feature and then created a new record in the structure inspection table and the StructureType will not autopopulate with the StructureType from the parent feature class.  Someone suggested I uncheck the Exclude from application evaluation, so I went back into my ArcGIS Pro Project and unchecked the Exclude from application evaluation, and now when trying to create a new Attribute Rule, after saving it turns gray instead of green.  I deleted the attribute rule and created a new one and I am still getting a gray box instead of green after saving. 

0 Kudos