Use attribute rule to enforce domain

1403
2
03-09-2022 10:44 AM
Labels (1)
Bud
by
Notable Contributor

The Attribute Rules documentation says:

Attribute rules are complementary to existing rules used in the geodatabase, such as domains and subtypes. For example, domains can be assigned to an attribute field to aid in the data collection process by providing a list of valid values for editors. Additionally, an attribute rule can be used to restrict values for an attribute field that are not part of the domain when performing a field calculation. After rules are added to a dataset, they can be evaluated as edits take place or at a later time.

Question:

What is involved in setting up an attribute rule to enforce a coded value domain? I.e. prevent non-domain values from being entered, even when tools like the field calculator are used.
- Do we need to hardcode the domain values in an IF statement in Arcade?
- Or can we reference the domain list in Arcade and use it to dynamically restrict values in a field?

Thanks.

0 Kudos
2 Replies
KimGarbade
Occasional Contributor III

I wrote a constraint rule (first image below). 

In the second image below you can see I added an attribute called DomTest to some test data.  I applied a domain call WetDry to that field.  Only a value of "WET" or "DRY" is allowed by the domain.  I then selected one record and used the field calculator to populate it with "KIM" (a clear violation of the domain) and it let me.

After I applied the constraint rule I tried to update one record again using the field calculator.  This time using "TIM" and the constraint rule stopped the edit.

KimGarbade_1-1646861363744.png

 

KimGarbade_0-1646861221409.png

 

Bud
by
Notable Contributor

Related:

if ($feature.structureheight >= 65)
{
    If (DomainName($feature, 'Material') == 'Steel')
    { return true; }
    else
    { return false; }
}
Else
{  return true; }

Validation attribute rule examples 

0 Kudos