Select to view content in your preferred language

Calculation Attribute Rule Fails with Domains

186
1
Jump to solution
07-17-2024 02:20 PM
VinceE
by
Frequent Contributor

I am trying to write an Attribute Rule that calculates the value in FieldA over to the value in FieldB. Both fields have the same Domain applied (domain named "TwoOptions"), and that Domain has two codes: {OPT1: Option1, OPT2: Option2}.

Here is the Field View, followed by the Domain.

VinceE_0-1721250197762.png

VinceE_1-1721250250253.png

Code below is a bit over-engineered because it's from a general template I try to follow.

// INPUTS
var inputFldVal = $feature.FieldA

// OUTPUTS
var outputFldName = "FieldB"

//---------------------------------------------------------------------//
// FUNCTIONS
function directCopyCalculation(inputFldVal) {
    /* If value exists in input column, copy to results dictionary for output column.*/
    var result = Dictionary("VALUE", null, "ERROR", null)

    // CHECK 1: Value in origin field exists.
    if (IsEmpty(inputFldVal))
        {return result}

    result["VALUE"] = inputFldVal
    return result
}

//---------------------------------------------------------------------//
// MAIN
var fldUpdates = Dictionary()

var result = directCopyCalculation(inputFldVal)
if (!IsEmpty(result["ERROR"]))
    // If any errors were found, return dict without any field updates.
    {return {"errorMessage": `ERROR: ${result}`}}
else
    // If no errors, update the results dict with the value for the new field.
    {fldUpdates[outputFldName] = result["VALUE"]}

Console(`RETURNING: ${{"result": {"attributes": fldUpdates}}}`)
return {"result": {"attributes": fldUpdates}}

 It works fine when selecting <Null> or either of the domain options in FieldA. Trying to update FieldB results in FieldB automatically updating back to whatever the value in FieldA is, which is fine and expected.

VinceE_2-1721250439578.png

If I intentionally break the Domain in FieldA using Field Calculator to populate an invalid value, that value also calculates over to FieldB. This is also fine, and what I would expect.

VinceE_3-1721250533518.png

The problem arises if I try to manually change FieldA back to a valid value. I get the following error. Hitting "OK" reverts FieldA's value back to "VALUE OUTSIDE DOMAIN".

VinceE_4-1721250623589.png

Seems like FieldB is being validated for allowable domain values BEFORE the newly updated valid value from FieldA is calculated over to FieldB. Am I missing an order-of-calculations thing here? Something else?

0 Kudos
1 Solution

Accepted Solutions
VinceE
by
Frequent Contributor

It appears the fix for this was simply checking "Exclude From Client Evaluation" box within the Attribute Rules interface for this particular rule.

I still need to read through the post here (entitled Attribute Rules - Exclude from Application Evaluation) to fully understand why that is though.

Attribute Rules - Exclude from Application Evaluat... - Esri Community

View solution in original post

0 Kudos
1 Reply
VinceE
by
Frequent Contributor

It appears the fix for this was simply checking "Exclude From Client Evaluation" box within the Attribute Rules interface for this particular rule.

I still need to read through the post here (entitled Attribute Rules - Exclude from Application Evaluation) to fully understand why that is though.

Attribute Rules - Exclude from Application Evaluat... - Esri Community

0 Kudos