Select to view content in your preferred language

Attribute Rule Enterprise 11.2 failing

381
4
04-03-2025 08:37 AM
WardMitchell2
Frequent Contributor

Hello, I trying to add an attribute rule to a branch versioned layer in enterprise 11.2.

The rule I'm trying to add will automatically add a new asset ID (alphanumeric) in a sequential matter when a new asset is added. 

I keep getting a variety of errors and have worked through them but I am currently stuck with the error "Error on line 11, Table not found $featureAsset_Id. 

I can not figured out why it doesn't see the table (the variable layer name is coming from the table). I am new to coding and have it working in python, but ESRI only has arcade as the option to use in the attribute rule window. My code is below.

Also dose anybody know if the attribute rule window in 11.4 will allow python as an option, Currently in 11.2 Arcade is the only option I'm seeing and it appears it cannot do what I want. 

 

0 Kudos
4 Replies
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @WardMitchell2,

A general rule of thumb, and even Esri has stated this, is that using alphanumeric IDs is generally unwise given that there is no method to accurately sort or filter those particular IDs. That being said, in your code you are trying to reference the name of the feature class when using FeatureSetByName. You have to explicitly use the name, like in the example below.

var F = FeatureSetByName( $datastore, 'This.Is.My.Feature.Class",['*'])

It will not work otherwise. There is documentation that you can lookup that verifies this.

0 Kudos
WardMitchell2
Frequent Contributor

Thanks @RPGIS , for the info. We made a little more progress. I wasn't aware of the general rule of thumb regarding alphanumeric IDs, we are linked to our asset information management system which is full of alphanumeric IDs so hopefully it doesn't have issues down the road and we haven't any issues as of yet. 

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

I tried doing the same things you did and was told repeatedly that you cannot despite that it is common in other programming languages. I am also a heavy python user and so it sometimes gets me when somethings work in python that don't necessarily translate well in arcade.

0 Kudos
WardMitchell2
Frequent Contributor

Our IT developer helped out and we have it working in arcade now and field maps. Here's the code.

var layerName = $feature['Asset_ID'];
var maxID = Max(Number(Mid($feature.Asset_ID, 2)));


var query = OrderBy(FeatureSetByName($datastore, 'SDE.signs', ['Asset_ID'], false),"Asset_ID DESC");
for (var feature in query) {
var currentID = DefaultValue(feature['Asset_ID'], "S-00000");

// Ensure currentID is a valid string and has the correct format
if (!IsEmpty(currentID) && TypeOf(currentID) == "String" && Count(currentID) > 2 && Left(currentID, 2) == "S-") {
var numPartStr = Mid(currentID, 2); // Extract numeric part safely
var numPart = Number(numPartStr);

// Ensure numPart is a valid number
if (!IsNan(numPart)) {
maxID = numPart;
break; // Only need the first (largest) value
}
}
}

// Generate the new sequential ID
//var newID = "S-" + Text(maxID+1, maxID); // Ensures format like "S-00001", "S-00002", etc.
var newID = maxID + 1;
var paddedID = Text(newID, "00000");
//var newID = "S-" + zero + (Number(maxID)+Number(1));

return "S-" + paddedID;

0 Kudos