Using FeatureSetByRelationshipName in Attribute Rules

766
1
03-04-2021 01:55 PM
Labels (2)
Z_Knoble
New Contributor

I am new to both Arcade and Attribute Rules. I am trying to create a calculation rule that is triggered by inserts, but my expression using FeatureSetByRelationshipName doesn't seem to be doing anything.

Here is the expression:

var test = FeatureSetByRelationshipName($feature, 'FH_MR_TR_REL', ["COMMENT_"], false);

return test;

 

I am applying the attribute rule to a table and trying to pull data from a field in a related feature class. 'FH_MR_TR_REL' is the relationship class and 'COMMENT_' is the field in the related feature class that I am trying to pull from.

I didn't get any errors, but the destination field remains null after inserting a new table record. I am sure I missing something obvious; any help would be appreciated.

0 Kudos
1 Reply
JimmyBowden
Occasional Contributor II

Because FeatureSetByRelationshipName returns a FeatureSet that may have more than one row. You can't just return it you have to get a value from a row.  Assuming you have a one to one relationship you can just get the First one:

if (!IsEmpty(test))
{
return First(test).COMMENT_
}

If you have one to many, you would have to apply more logic to decide which one you want.

0 Kudos