<?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: ATTRIBUTE CONSTRAINT RULE (Limit Characters) in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1295153#M69767</link>
    <description>&lt;P&gt;Hi Josh, thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Before creating the attribute restriction rule, I decided to load the script into an attribute calculation rule pointing to another field, in order to see what values ​​the script was generating (just changing true to 'OK' and false to 'NO').&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I've playing around some time with your script but it didn't work, I think is because the true/false values are inverted (if I put 'D' as input the script will skip the if clause and 'test' will take the input as valid), I switched them but it didn't work either. So, again following the code and debugging it in my brain (pretending I knew what I was doing &lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;) I realized that it only worked when you put a invalid character at the very beginning, but if that invalid character was preceded by one or more (like 'ABCD') valid characters the srcipt will skip the 'if()' again and keeps the text as valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After a few hours of scripting philosophy&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt; I&amp;nbsp;thought that instead of compairing every allowed character with my input text it would be better to compare each character of the input with the allowed ones; when a character of my input doesn't match the 'finders' array the if clause change 'test' value to 'NO' (or false), so the script ended like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// default to OK
var test = 'OK'

// array of things to search for
var finders = [
    'A',
    'B',
    'C'
]

//compairing each character in 'name' field with allowed characters in 'finders'
for (var f in $feature.name) {
    //if any character in 'name' field doesn't match with allowed characters in 'finders' variable test changes to 'NO'
    if (find($feature.name[f], finders) == -1) {
        test = 'NO'
        
        // as soon as a match is found, no need to keep checking
        break
    }
}

return test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I tested my script, it appears to work just fine, but I would prefer if you check it please, because I'm quite new writing code so I don't want the script has silly newbie code issues&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again, thanks a lot, not only for your reply but showing me the rigth path to follow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;/P&gt;&lt;P&gt;- Eduardo Ardila&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 20:20:14 GMT</pubDate>
    <dc:creator>EDUARDOARDILARINCON</dc:creator>
    <dc:date>2023-06-01T20:20:14Z</dc:date>
    <item>
      <title>ATTRIBUTE CONSTRAINT RULE (Limit Characters)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1294992#M69755</link>
      <description>&lt;P&gt;Hi Everyone!&lt;/P&gt;&lt;P&gt;I'm trying to create a constraint attribute rule that limits the types of characters in a field, I've tried using the find() function which returns -1 in case the character is not found within the typed text. This workflow works perfect when I only search for one character/word, unfortunately I need to limit the field to certain specific characters regardless of their order , length or if they are repeated within the text string (eg A, B, C. and no matter if the field contains AA, ACB, BAC, BBAC). I tried using find() in conjunction with the operator || but i failed miserably&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;BR /&gt;So here´s the piece of code I tried to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var test

test= find(('A'||'B'||'C'),$feature.name)

if (test&amp;gt;=0) {
return true;
}
else {
return false;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate so much your comments/suggestions.&lt;BR /&gt;&lt;BR /&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 15:09:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1294992#M69755</guid>
      <dc:creator>EDUARDOARDILARINCON</dc:creator>
      <dc:date>2023-06-01T15:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: ATTRIBUTE CONSTRAINT RULE (Limit Characters)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1295004#M69756</link>
      <description>&lt;P&gt;Yeah, the &lt;STRONG&gt;find&lt;/STRONG&gt; function can't handle multiple input strings. (Same with &lt;STRONG&gt;replace&lt;/STRONG&gt;, too.)&lt;/P&gt;&lt;P&gt;You can search multiple things easily enough using an array and a loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// default to true
var test = true

// array of things to search for
var finders = [
    'A',
    'B',
    'C'
]

for (var f in finders) {
    if (find(finders[f], $feature.name) != -1) {
        test = false
        
        // as soon as a match is found, no need to keep checking
        break
    }
}

return test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 15:28:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1295004#M69756</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-06-01T15:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: ATTRIBUTE CONSTRAINT RULE (Limit Characters)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1295153#M69767</link>
      <description>&lt;P&gt;Hi Josh, thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Before creating the attribute restriction rule, I decided to load the script into an attribute calculation rule pointing to another field, in order to see what values ​​the script was generating (just changing true to 'OK' and false to 'NO').&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I've playing around some time with your script but it didn't work, I think is because the true/false values are inverted (if I put 'D' as input the script will skip the if clause and 'test' will take the input as valid), I switched them but it didn't work either. So, again following the code and debugging it in my brain (pretending I knew what I was doing &lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;) I realized that it only worked when you put a invalid character at the very beginning, but if that invalid character was preceded by one or more (like 'ABCD') valid characters the srcipt will skip the 'if()' again and keeps the text as valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After a few hours of scripting philosophy&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt; I&amp;nbsp;thought that instead of compairing every allowed character with my input text it would be better to compare each character of the input with the allowed ones; when a character of my input doesn't match the 'finders' array the if clause change 'test' value to 'NO' (or false), so the script ended like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// default to OK
var test = 'OK'

// array of things to search for
var finders = [
    'A',
    'B',
    'C'
]

//compairing each character in 'name' field with allowed characters in 'finders'
for (var f in $feature.name) {
    //if any character in 'name' field doesn't match with allowed characters in 'finders' variable test changes to 'NO'
    if (find($feature.name[f], finders) == -1) {
        test = 'NO'
        
        // as soon as a match is found, no need to keep checking
        break
    }
}

return test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I tested my script, it appears to work just fine, but I would prefer if you check it please, because I'm quite new writing code so I don't want the script has silly newbie code issues&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once again, thanks a lot, not only for your reply but showing me the rigth path to follow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":call_me_hand:"&gt;🤙&lt;/span&gt;&lt;/P&gt;&lt;P&gt;- Eduardo Ardila&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 20:20:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-constraint-rule-limit-characters/m-p/1295153#M69767</guid>
      <dc:creator>EDUARDOARDILARINCON</dc:creator>
      <dc:date>2023-06-01T20:20:14Z</dc:date>
    </item>
  </channel>
</rss>

