I've been trying to use this approach to get the count of related objects in an attribute rule calculation. I'm trying to count the number of objects related to a feature which is from a feature service, and set the count on an attribute of the feature called 'RelCount'. I use the $datastore instead of $map above. Here's the arcade for the rule titled 'setRelCnt':
var id = $feature.GlobalID;
var sql = "Parent_GlobalID = '" + id + "'";
var asset_view = FeatureSetByName($datastore,"GISP.PE_GIS.SimpleUnits");
var assets = Filter(asset_view, sql);
var cnt = Count(assets);
return cnt
Here's how I defined it in Pro:
I assign the Rule and share the map to create the feature service. When I edit a feature in Pro to trigger the rule, I get this error that the table "GISP.PE_GIS.SimpleUnits" is not found.
However, you can see the table from Portal:
Is there an easier way to get the number of related records to a feature using Arcade? Should I be able to get the table "GISP.PE_GIS.SimpleUnits" and count the related records when updating a feature from a branch versioned feature service?