Can an Arcade Attribute Rule access attributes from a related table field to populate/calculate a feature class field??

1084
2
02-05-2020 02:49 PM
BenjaminGrover
New Contributor II

I feel like I'm trying to do something very simple, but Arcade is kicking my butt so far.  All I want to do is populate a field in my feature class layer with the result of a simple field calculation that multiples one integer field by a field from a 1 to many related table...  In my situation, there may be many features from my layer, that are related to just 1 table record.  Any help would be appreciated. arcade script attribute rules rules‌@

#arcade‌ arcade expressions #arcade attribute expressions

0 Kudos
2 Replies
BenjaminGrover
New Contributor II

Here is what I've come up with, the error I get is that the output is resulting in a NaN, or Infinity.. I'm not sure how to address that.

var ShpSize = Area($feature, 'square-feet');

var RelTblFld = FeatureSetByName($datastore, "RelatedTableName", ["LongIntField1"]);

var Output = Round((RelTblFld)*(ShpSize), 2);

return Output

0 Kudos
WillHouston
New Contributor III

How many items are you trying to multiply together to get the result? Do you have a relationship class set up for the 1:Many relationship? You could try something like:

var results = FeatureSetByRelationshipName($feature, "relationship_class_name", ['LongIntField1'], false);

product = Area($feature, 'square-feet')

for (var r in results) { product = product * r.LongIntField1; }

return product;

I might be misunderstanding which sign of the 1:many relationship you're trying to access, but it should work either way. If you're multiplying something from the 1 side to the many side, just replace the for loop with

var r = First(results);