Error 001841 The Class was not found %s In arcade attribute rule

1299
5
07-28-2020 01:39 PM
JoeBorgione
MVP Esteemed Contributor

More of Joe's Awesome Adventures with the Address Data  Management Solution and attribute rules...

I found a thread thread that mentions the same error ArcGIS PRO 2.1.3 brought new defect - ERROR 001841: The class was not found%s. Failed to execute (As... from 2018.  I'm getting the same basic error when trying to validate the Centerline ID and Copy Road Aliases rule in the Address Data Management Solution that I'm trying to get to work in an EGDB environment.

The table AliasRoadName is present in the $datastore (my egdb where the centerlines reside as well.)  This rule is integral to the Split Intersecting Road Tool so if the Centerline ID and Copy Road Aliases rule doesn't work, neither will the  Split rule.  The rule that won't validate is a copy from my original proof of concept project that I got to work in a fgdb, and it worked there.

I'm wondering if this is just a generic error that is being returned that is meaningless for the issue at hand, but as with anything arcade, you are at the mercy of what it returns when it fails.  Below is the rule that tosses the error.  You'll notice i don't reference lines 5 & 6 further down in line line 14, opting just for the number my sequence returns. 

Earlier today, I posted List Database Sequences for Enterprise Geodatabase in which I question how to verify if a sequence exists in an EGDB:  I created a scratch point feature class and created a rule that calls the sequence listed below and created a point.  The sequence does in fact exist and the proper incremented sequence value populates the appropriate field in the point attribute table, so that proves to me that a sequence can be added and utilized in an egdb.

// This rule will create a new unique id when a road centerline is created
// This will also copy related road alias names for any roads that were added as a result of a split

// Define the leading text and the delimiter for the ID
var prefix = "MSD"
var join_char = "-"

// Define any fields to be copied from the road name aliases table (lower case)
var alias_field_names = ["roadpremod", "roadpredir", "roadpretype", "roadpretypesep", "roadname", "roadtype", "roadpostdir", "roadpostmod", "fullname", "municipality"]

// If the road was created from a split its oirginal id will have a prefix of '::'
// We will use this to find the original road and its related alias road names
if (Left($feature.UNIQUE_ID, 2) == "::" || IsEmpty($feature.UNIQUE_ID)) {
    var id = NextSequenceValue("CenterlineUniqueID")
    
    // If the UNIQUE_ID is not set return the new id
    if (IsEmpty($feature.UNIQUE_ID)) return id;
   
    // Find the original ID of the road that was split
    var original_id = Mid($feature.UNIQUE_ID, 2, Count($feature.UNIQUE_ID) - 2);
    if (IsEmpty(original_id)) return id;
    
    // Find all the related road alias names for the split road
    // Store an add for every road alias and related it to the new road that was added after the cut
    var adds = []
    var roadNameAliases = Filter(FeatureSetByName($datastore, "AliasRoadName"), "UNIQUE_ID = '" + original_id + "'");
    for (var roadNameAlias in roadNameAliases) {
        var featureAttributes = Dictionary(Text(roadNameAlias))['attributes'];
        var newAttributes = {};
        for (var k in featureAttributes) {
            if (IndexOf(alias_field_names, Lower(k)) > -1 && featureAttributes != null) {
                newAttributes = featureAttributes;
            } else {
                continue;
            }
        }
        newAttributes['UNIQUE_ID'] = id
        adds[Count(adds)] = {
            'attributes': newAttributes
        }
    }
    
    // Using the edit parameter return the list of updates and adds for the intersecting roads and a list of adds for related road alias names
    return {
        'result': id,
        'edit': [{'className': 'AliasRoadName', 'adds': adds}]
    };
}
else {
   return $feature.UNIQUE_ID
}

Kory Kramer

Jonathan Farmer

Chris Fox

Xander Bakker

That should just about do it....
0 Kudos
5 Replies
JoeBorgione
MVP Esteemed Contributor

Some time  later...

I just went ahead and saved the the rule in spite of the red box and error. I then simply added a new centerline without splitting an existing centerline.  I am am able to do that and the ID sequence fires. Intrigued, I added a second new centerline that intersects the first new center line.  Holy cow!  That works too!  Mind you, I have not updated any of the attribute data in these new roads.

However... Now when I try to add a new centerline that splits one of my existing centerlines, I get the error shown below, which is one I fought for quite sometime when working in the fgdb arena and my proof of concept project.  I could never figure it out; the only way I am able to use the Address Data Management Solution is to use the ESRI prescribed feature class names and schemas.

Chris Fox

That should just about do it....
0 Kudos
ChrisFox
Esri Regular Contributor

Joe Borgione‌, I believe that error is occurring because it is trying to insert a new record and add an attribute for a field with the name 'toleft', but you don't have 'toleft' in your schema. You will need to find and replace all references to this field with the corresponding field in your schema.

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Thanks Chris Fox-   I thought I had done that, but with the dawn of a new day, and fresh cup of coffee, another adventure begins!  I'll keep you posted here.

That should just about do it....
0 Kudos
JoeBorgione
MVP Esteemed Contributor

Chris Fox‌:

In the split intersecting road rule, there is only one reference to 'toleft':

        // Store an update for the intersecting road with the first geometry from the cut and the new right to and left to value 
  var attributes = {}
  if (newToFromRight[0] != null) attributes['toright'] = newToFromRight[0];
  if (newToFromLeft[0] != null) attributes['toleft'] = newToFromLeft[0];
        updates[Count(updates)] = {
            'objectID': road.OBJECTID,
            'attributes': attributes,
            'geometry': firstGeometry
        }‍‍‍‍‍‍‍‍‍

working my way back upstream in the rule I have mapped my from/to address fields near the top:

    if (validCut) {

        // Get the address range of the intersecting road
        var fromRight = road.FROMADDR_R;                                             
        var toRight = road.TOADDR_R;
        var fromLeft = road.FROMADDR_L;
        var toLeft = road.TOADDR_L;

        var firstGeometry = null;
        var secondGeomArray = [];
        var firstPoint = Geometry(road).paths[0][0];

        // Loop through each geometry in the cut
        // Store the geometry including the first vertex of the orginal road as the first geometry
        // Collect all other geometries in an array
        for (var i in geometries) {
            if (Equals(firstPoint, geometries.paths[0][0])) {
                firstGeometry = geometries;
            } else {
                secondGeomArray[Count(secondGeomArray)] = geometries;
            }
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Seems as though I should be good to go.  As I study the rule, there is a function called newToFrom that does a little magic calculating the new ranges based on percentage and from the error, it appears not to be creating the values as expected.

That should just about do it....
0 Kudos
JoeBorgione
MVP Esteemed Contributor

In May I had posted this Arcade Attribute Rule Error which describes the same error I'm receiving now.  Back then, the reason I was getting it was because I had neglected to add the Centerline ID and Copy Alias rule. However, once I figured that out and included that rule, I was working solely with the esri schema and feature class names and everything started to work for me in the fgdb realm with my data in those schemas and feature classes.

If I disable that rule now, I get the same error, but I'm not at all sure what the connection is. So with or without the Centerline ID and Copy Alias rule it tosses the exact same error. 

Chris Fox

That should just about do it....
0 Kudos