<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Constraint rule field length in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1178254#M430</link>
    <description>&lt;P&gt;It's probably because you're checking length for null, not name_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 May 2022 05:50:38 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-05-30T05:50:38Z</dc:date>
    <item>
      <title>Constraint rule field length</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1177595#M427</link>
      <description>&lt;P&gt;Hi, I created a constraint that checks if an editor has entered a valid number into a field (length of 12).&amp;nbsp;&lt;/P&gt;&lt;P&gt;var length = Count(Text($feature.name_id));&lt;/P&gt;&lt;P&gt;if&amp;nbsp; ((($feature.name_id!=$originalfeature.name_id) &amp;amp;&amp;amp; (length!=12))&amp;nbsp;&lt;/P&gt;&lt;P&gt;{return false}&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;{return true}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var length = Count(Text($feature.name_id));&lt;/P&gt;&lt;P&gt;if&amp;nbsp; (($feature.name_id!=$originalfeature.name_id) &amp;amp;&amp;amp; ((length!=12) || IsEmpty(length)))&lt;/P&gt;&lt;P&gt;{return false}&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;{return true}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 16:27:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1177595#M427</guid>
      <dc:creator>V1212</dc:creator>
      <dc:date>2022-05-26T16:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Constraint rule field length</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1178254#M430</link>
      <description>&lt;P&gt;It's probably because you're checking length for null, not name_id.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 05:50:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1178254#M430</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-05-30T05:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Constraint rule field length</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1178317#M432</link>
      <description>&lt;P&gt;Thanks for the help and your tip!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 12:57:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-rule-field-length/m-p/1178317#M432</guid>
      <dc:creator>V1212</dc:creator>
      <dc:date>2022-05-30T12:57:46Z</dc:date>
    </item>
  </channel>
</rss>

