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?
Solved! Go to Solution.
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);
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);
Thanks! I will try this out.
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.