Validation problem with checking domains compliance

301
3
Jump to solution
02-12-2024 12:55 PM
Labels (1)
DeanAnderson2
Occasional Contributor II

I am testing validation rules.  We have imported a lot of data and I want to implement validation rules to assist users in reviewing attribute values that need to be in the attribute domain.  I am using ArcPro 3.2+.  (I know I can do this from with the Attributes tab but want to use attribute validation rules. ) 

 I have a domain with ALL county values 1-36 for a field called County.  In my feature class (Taxcode) I selected a polygon and assigned it a null value (putting it outside the domain).  I have created a couple of different arcade scripts to do the validation but both return all features in error when using the error inspector.  I have looked at available examples and can not find this specific example.  I did find code that looks at pole heights and another that includes subtypes.  I have not been successful at using these examples to create my own SIMPLE approach.  Here are the two ways I have done it. 

Example 1: 

return (Includes(Domain($feature,'County').codedvalues,$feature.County))

Example 2: 

var CountyDomains = Domain($feature,'County')
var ValidCodes = []
var ValidCodes = CountyDomains["codedValues"]
return (Includes(ValidCodes,$feature.County))

Both are valid expressions.  In the error inspector both identify all features in the feature class as being in error.   Its got to be doing something simple.  What am I doing wrong? 

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Scott_Harris
Esri Regular Contributor

@DeanAnderson2 

I found an example that should work for you:

function exists(ar, e) {
    for (var i = 0; i < count(ar); i++)
        if (ar[i].code == e) return true
    return false
} 
//get the domain
var d = Domain ($feature, "County");

//search the domain and see if the value is inside the domain.
return exists(d.codedValues, $feature.County);

 

From https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/domain-subtypes-and-the-schema-...

 

View solution in original post

0 Kudos
3 Replies
Scott_Harris
Esri Regular Contributor

@DeanAnderson2 

I found an example that should work for you:

function exists(ar, e) {
    for (var i = 0; i < count(ar); i++)
        if (ar[i].code == e) return true
    return false
} 
//get the domain
var d = Domain ($feature, "County");

//search the domain and see if the value is inside the domain.
return exists(d.codedValues, $feature.County);

 

From https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/domain-subtypes-and-the-schema-...

 

0 Kudos
DeanAnderson2
Occasional Contributor II

Thanks!   I will try this out.  

0 Kudos
DeanAnderson2
Occasional Contributor II

It worked great - Thanks.  I am not sure why mine did not but I do not care and will do a bit more research on why.