I want to create a field that would flag a row if its values don’t match its domains.
Is there a way to populate such a field using an Arcade calculation attribute rule?
I’m aware that it’s possible to prevent invalid rows in the first place using a constraint attribute rule. That’s a valid option. But I also want to experiment with a flag too. Thanks.
Edit: Unfortunately, I forgot to mention that the table has subtypes (with domains).
Solved! Go to Solution.
Point FC with coded value domain ["Value 1", "Value 2", "Value 3"] on TextField:
JohannesLindner_0-1656085219861.png
Using CalculateField, I can insert other values (same works with arcpy cursors and attribute rules):
JohannesLindner_1-1656085353003.png
JohannesLindner_3-1656086354261.png
Calculation Attribute Rule on that point fc, field IntegerField, triggers insert & update
function code_is_in_domain(domain_dict, code) {
for(var i in domain_dict.codedValues) {
if(domain_dict.codedValues[i].code == code) {
return true
}
}
return false
}
var attributes = Dictionary(Text($feature)).attributes // a dictionary
for(var field in attributes) { // loop through the dictionary keys ( = field names)
var domain_dict = Domain($feature, field)
if(domain_dict != null && !code_is_in_domain(domain_dict, $feature[field])) {
return 0//"INVALID"
}
}
return 1//"VALID"
(you could of course also populate a text field with that rule, or you could return booleans and use it as constraint rule)
I can still input values that are not in the domain, but now the flag gets set:
JohannesLindner_2-1656086284856.png
Point FC with coded value domain ["Value 1", "Value 2", "Value 3"] on TextField:
JohannesLindner_0-1656085219861.png
Using CalculateField, I can insert other values (same works with arcpy cursors and attribute rules):
JohannesLindner_1-1656085353003.png
JohannesLindner_3-1656086354261.png
Calculation Attribute Rule on that point fc, field IntegerField, triggers insert & update
function code_is_in_domain(domain_dict, code) {
for(var i in domain_dict.codedValues) {
if(domain_dict.codedValues[i].code == code) {
return true
}
}
return false
}
var attributes = Dictionary(Text($feature)).attributes // a dictionary
for(var field in attributes) { // loop through the dictionary keys ( = field names)
var domain_dict = Domain($feature, field)
if(domain_dict != null && !code_is_in_domain(domain_dict, $feature[field])) {
return 0//"INVALID"
}
}
return 1//"VALID"
(you could of course also populate a text field with that rule, or you could return booleans and use it as constraint rule)
I can still input values that are not in the domain, but now the flag gets set:
JohannesLindner_2-1656086284856.png