Attribute Rule Update Trigger Preventing Field Updates Due to Association Status

309
1
10-24-2024 06:53 AM
GIS_Ozzy
New Contributor

Hello everyone,

I’m encountering an issue with an Attribute Rule that is designed to establish a containment relationship when a feature is inserted into the main.StructureBoundary layer. The rule works perfectly for establishing the container and content relationships upon feature insertion.

However, when I enable the update trigger, I face a problem. If I try to update an attribute of a feature that already has an association, the update trigger attempts to re-establish the existing association, leading to the error: "association status already exists."

In some cases, I need to update attributes of features that already have an established association. I would like to be able to do this without disabling the update trigger.

Current Rule

 

var sjFeatureSet = FeatureSetByName($datastore, "main.StructureBoundary", ["objectid"] ,false)
// Asset Group 53 (StructureBoundary T_HUCRE Subtypes Code)
// Asset Type 190-191-192 (StructureBoundary T_HUCRE Domain Code)
var T_HUCRE_FeatureSet = Filter(sjFeatureSet, "ASSETGROUP in (53) AND ASSETTYPE in (190,191,192)")
//buffer
var g = buffer($feature, 0)

var intersected_T_HUCRE = Intersects(T_HUCRE_FeatureSet,g)

if (count(intersected_T_HUCRE) == 0)
return $feature.KuralAciklama;

var pole = first(intersected_T_HUCRE)

return {
"edit":
[
{
"className": "main.StructureBoundary",

"updates":
[
{
"objectID": pole.objectid,
"associationType": 'container'
}
]
}
]
}

 

 

My Goal:

  • Keep the update trigger enabled.
  • Allow attribute updates without triggering the "association status already exists" error.
  • Only attempt to establish a new containment relationship if one does not already exist.

Has anyone encountered a similar issue, or could suggest how I can modify the rule to avoid this problem?

Thank you in advance!

0 Kudos
1 Reply
TedHoward2
Esri Contributor

Not sure why the update trigger needs to be enabled for this rule but you could just exit early if $feature already has an association. It depends on your particular scenario and what other associations could exist, but it would look something like this

if ($editcontext.editType == "UPDATE"){
    var assoc = FeatureSetByAssociation($feature, "container")
    if (Count(assoc) > 0) return
}