Select to view content in your preferred language

Use attribute rule to enforce domain

2327
3
03-09-2022 10:44 AM
Bud
by
Esteemed 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
3 Replies
KimGarbade
Frequent Contributor

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

 

JamesE
by
Occasional Contributor

Hi KimGarbade, any luck apply this rule to multiple fields at same time?

i managed to get it work but with an error message returned..

0 Kudos
Bud
by
Esteemed 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