Hi,
This is my system configuration:
ArcGIS Pro 2.8
Electric Utility Network Version 4
ArcGIS Enterprise 10.8.1
SQL Server 2017
I'm getting this error when trying to save the rule (error and code images at the end) to my enterprise geodatabase (Utility Network in SQL database). The problem seems to be related to the code in the rule because I could save other rules with different code after the error. I think it has to do with my using the $map global in the Attribute Rule Calculation profile. The Arcade documentation is a little confusing about using the $map global in this profile. In the Profile section of the documentation (Profiles | ArcGIS Arcade) it doesn't include the $map global, but the Type System FeatureSetCollection section (Type System | ArcGIS Arcade) of the documentation mentions that the $map global can be used in the Attribute Rules profiles.
The other rules that I was able to save are using the $datastore global to access other class in the database. This rules is trying to access a feature class added to the map from a file geodatabase. I'm trying to avoid having to add the feature class in the file geodatabase to the enterprise geodatabase and then use $datastore global. This process has worked in the past, but now I'm having problems deleting those temporary feature classes from the enterprise geodatabase (Utility Network SQL database) when I don't need them anymore.
So, what I'm trying to do is find a way to allow the Attribute Rule associated to a Utility Network feature class in the enterprise geodatabase to extract data from a feature class in a file geodatabase. I'm not sure if the $map global is the best way to do that.



// ************* User Variables *************
// This section has the functions and variables that need to be adjusted based on your implementation
// The field the rule is assigned to
var field_value = $feature.notes;
var source_layer = 'Poles_to_Riser_Disconnect_Match';
var search_distance = 200;
var search_unit = 'feet';
var feat_globalid = $feature.globalID;
// Asset_type allowed
var valid_asset_types = [565]; // 565 - Overhead Cutout Fused Load Break from Device Class
// ************* End User Variables Section *************
// Checking for allowed asset types
if (indexof(valid_asset_types, $feature.assettype) == -1) {
return field_value;
}
//Find the closest pole
var fsSource = FeatureSetByName($map, source_layer,["*"], false)
var fBuffer = Buffer(Geometry($feature), search_distance, search_unit)
var fsClosest = Intersects(fsSource, fBuffer)
var minDistance = Infinity
var fFuse = First(fsClosest)
if (IsEmpty(closestp)) {
return field_value;
}
return fFuse['STREET']