Hi, I created a constraint that checks if an editor has entered a valid number into a field (length of 12).
var length = Count(Text($feature.name_id));
if ((($feature.name_id!=$originalfeature.name_id) && (length!=12))
{return false}
else
{return true}
I want to modify this rule so that an editor can remove an incorrect 12 char text from the field without the rule getting triggered. I've tried different variations of this expression but it doesn't work as intended. I get an error message when I try to blank the field.
var length = Count(Text($feature.name_id));
if (($feature.name_id!=$originalfeature.name_id) && ((length!=12) || IsEmpty(length)))
{return false}
else
{return true}
Thanks in advance!
Solved! Go to Solution.
It's probably because you're checking length for null, not name_id.
As a side note: just use multiple if statements. Your statement is hard to read and understand because of all the parantheses in there, and the $feature stuff doesn't help...
var name_id = $feature.name_id
var o_name_id = $originalfeature.name_id
if(name_id == o_name_id) { // you're not changing it
return true
}
if(IsEmpty(name_id)) { // it's blank
return true
}
var len = Count(Text(name_id))
return len == 12
It's probably because you're checking length for null, not name_id.
As a side note: just use multiple if statements. Your statement is hard to read and understand because of all the parantheses in there, and the $feature stuff doesn't help...
var name_id = $feature.name_id
var o_name_id = $originalfeature.name_id
if(name_id == o_name_id) { // you're not changing it
return true
}
if(IsEmpty(name_id)) { // it's blank
return true
}
var len = Count(Text(name_id))
return len == 12
Thanks for the help and your tip!