Hello @MikeMillerGIS
When applying an asset package to Postgres 14 Enterprise 11.3, I noticed that some of my attribute rules did not apply while others did.
Only Constraint rules seems concerned in my case
Here is a sample code of a constraint rule that did apply (intended to check if a certain field has unique value if not null) :
if($feature.NDB == null){
return True
}
else{
var concession = $feature.CONCESSI;
var gid = $feature.GLOBALID
var fsBrt = Filter(FeatureSetByName($datastore, "ElectricDevice", ["GLOBALID", "ASSETGROUP", "NDB", "NSRNDB"], False), "ASSETGROUP = 10 AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
var uniqueIds = [];
var i = 0;
for (var brt in fsBrt) {
if (brt.NDB != null){
uniqueIds[i++] = brt.NSRNDB
}
}
var calcNsrNdb = concatenate($feature.NSR,'/',$feature.NDB)
if (Includes(uniqueIds, calcNsrNdb)){
return False
}
else{
return True
}
}
And a very similar Constraint rule that will not apply :
if ($feature.NUMERO == null){
return True
}
else{
var assetGroup = $feature.ASSETGROUP
var concession = $feature.CONCESSI;
var gid = $feature.GLOBALID
var uniqueIds = [];
var i = 0;
var table = "ElectricJunction"
if (Includes([11, 12, 13, 15, 16], assetGroup)){
table = "ElectricDevice"
}
if (Includes([16, 33], assetGroup)){
var HtaNoeudfeatureDataset = Filter(FeatureSetByName($datastore, "ElectricJunction", ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = 33 AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
var HtaInterfeatureDataset = Filter(FeatureSetByName($datastore, "ElectricDevice", ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = 16 AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
for (var feature in HtaNoeudfeatureDataset) {
if (feature.NUMERO != null){
uniqueIds[i++] = feature.SIG_ID_UNIQUE
}
}
for (var feature in HtaInterfeatureDataset) {
if (feature.NUMERO != null){
uniqueIds[i++] = feature.SIG_ID_UNIQUE
}
}
}
else{
var featureDataset = Filter(FeatureSetByName($datastore, table, ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = @assetGroup AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
for (var feature in featureDataset) {
if (feature.NUMERO != null){
uniqueIds[i++] = feature.SIG_ID_UNIQUE
}
}
}
if (Includes(uniqueIds, $feature.SIG_ID_UNIQUE)){
return False
}
else{
return True
}
}
I guess it may be related to the "table" variable used to manage the table used in the featureSetByName function. In general, Apply Asset Package will add geodatabase name as a prefix, like "my_gdb.ElectricJunction" but in this case it fails without any error. Apply Asset Package will end normally, but the rule will not apply.
Do you have any idea how to resolve this ?
In the ap_workspace folder, is there any reported in the GP log? Can you verify the AR is in the xml file in the apworkspace folder?
Here is the log regarding the AR in the log file :
arcpy.gp.UpdateSchema(
"D:\\....myfolder.....\\myNetwork\\ElectricDevice",
"D:\\arcgispro\\creation_geodatabase\\AP_Workspace4\\xml\\ElectricDevice_2_EditorTracking-AttributeRules.xml",
)
EnableEditorTracking 1
AddAttributeRule 40
--> I have 44 AR in this feature class and in the Asset Package. 4 are missing and correspond to the code I sent you.
But yes, you can see here that the AR is in the AP_UN.xml file :
If they are in the file, we are sending them to the GDB. If the gdb is failing to add them and not report an error, that is an issue. Any chance we can get the entire AP Workspace?
I just sent it to you by mail.
Regards
I finally turn this :
var table = "main.ElectricJunction"
if (Includes([11, 12, 13, 15, 16], assetGroup)){
table = "main.ElectricDevice"
}
var featureDataset = Filter(FeatureSetByName($datastore, table, ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = @assetGroup AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
into this :
if (Includes([11, 12, 13, 15, 16], assetGroup)){
var featureDataset = Filter(FeatureSetByName($datastore, "main.ElectricJunction", ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = @assetGroup AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
}
else{
var featureDataset = Filter(FeatureSetByName($datastore, "main.ElectricDevice", ["GLOBALID", "NUMERO", "SIG_ID_UNIQUE"], False), "ASSETGROUP = @assetGroup AND CONCESSI = @concession AND GLOBALID <> @gid AND CYCLEVIE NOT IN (4,7)");
}
It is now working fine, but not sure why it was not importing with the asset package but working once applied on the UN table
Sorry, I must have missed your mail, been a busy few weeks. I will try to look at it and see why the import was dropping it.