<?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 ATTRIBUTE RULE ISSUE in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307272#M994</link>
    <description>&lt;P&gt;Hi Mike! First of all, thanks a lot for your response, I've tried your code, I added some missing&amp;nbsp;parenthesis but the expression builder shows the error "Uknown Function" I guess it doesn't recognize "evaluate" as a built-in function in Arcade.&lt;/P&gt;&lt;P&gt;I'll stay tuned for your response, I really need some help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2023 14:20:58 GMT</pubDate>
    <dc:creator>EDUARDOARDILARINCON</dc:creator>
    <dc:date>2023-07-11T14:20:58Z</dc:date>
    <item>
      <title>CONSTRAINT ATTRIBUTE RULE ISSUE</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307041#M992</link>
      <description>&lt;P&gt;Hi everyone! I'm trying to build a constranit attribute rule on a feature, in this feature I have 6 fields (Lentgh, Lentght_Na, Width, Width_NA, Radius, Radius_NA), 3 main fields (Length, Width, Radius) referred to a domain that contains 2 options (Available, Not Available) and other 3 secondary&amp;nbsp; fields (Length_NA, Width_NA, Radius_NA) that must be completed using one option af another domain (Under construction, demolished, pending) only if their respective main fields contain the option "Not Available", in case that the "Available" option is selected, the "_NA" fields must be null, so basically I need to create an alert that appears when the main field is 'Not Available' and the '_NA' field is null.&lt;/P&gt;&lt;P&gt;First, I've created constraint rules for each couple of fields like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.length == 'Not Available' &amp;amp;&amp;amp; isempty($feature.length_NA)) {
        return false
    }
    else {
        return true
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;That piece of code was useful at the beginning, but I've realized that&amp;nbsp; I have so many layers, and so many other fields that uses the same structure to validate the data, so repeating this code for every single pair of fields could be time consuming.&lt;/P&gt;&lt;P&gt;According to the above,&amp;nbsp; I've modified the script using a function an then loading each pair of fields as an input data:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function evaluate(field1,field2) {
    if (field1 == 'nilReason' &amp;amp;&amp;amp; isempty(field2)) {
        return false
    }
    else {
        return true
    }
}

evaluate($feature.width, $feature.width_NA)
evaluate($feature.radius, $feature.radius_NA)
evaluate($feature.length, $feature.length_NA)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I tested it, the alert only appears when the last case (Length) matches the conditions in the 'if' clause, the other two pair of cases are not working (the alert doesn't appear no matter what's inside the fields).&lt;/P&gt;&lt;P&gt;I'm barely new to coding and I have no idea where is the problem, so once again I request your help.&lt;/P&gt;&lt;P&gt;Thanks a lot!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307041#M992</guid>
      <dc:creator>EDUARDOARDILARINCON</dc:creator>
      <dc:date>2023-07-10T19:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: CONSTRAINT ATTRIBUTE RULE ISSUE</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307193#M993</link>
      <description>&lt;P&gt;This is probably the most efficient&amp;nbsp;way, as you can exit after the first item you encounter that is false:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var cond = [[$feature.width, $feature.width_NA],[$feature.radius, $feature.radius_NA],[$feature.length, $feature.length_NA]]
for (var i in cond) {
     if (cond[i][0] == 'nilReason' &amp;amp;&amp;amp; isempty(cond[i][1])) {
         return false
     }
}
return true;&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;If you want a custom error message per field combo:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var results = [];
var cond =  [[$feature.width, $feature.width_NA,"Msg A"],[$feature.radius, $feature.radius_NA,"Msg B"],[$feature.length, $feature.length_NA,"Msg C"]]
for (var i in cond) {
     if (cond[i][0] == 'nilReason' &amp;amp;&amp;amp; isempty(cond[i][1])) {
         push(results,cond[i][2]);
     }
}
if (Count(results) == 0){
    return true;
}
return {'errorMessage':  Concatenate(results,", ")}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 15:25:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307193#M993</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-07-11T15:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: CONSTRAINT ATTRIBUTE RULE ISSUE</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307272#M994</link>
      <description>&lt;P&gt;Hi Mike! First of all, thanks a lot for your response, I've tried your code, I added some missing&amp;nbsp;parenthesis but the expression builder shows the error "Uknown Function" I guess it doesn't recognize "evaluate" as a built-in function in Arcade.&lt;/P&gt;&lt;P&gt;I'll stay tuned for your response, I really need some help here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307272#M994</guid>
      <dc:creator>EDUARDOARDILARINCON</dc:creator>
      <dc:date>2023-07-11T14:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: CONSTRAINT ATTRIBUTE RULE ISSUE</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307307#M995</link>
      <description>&lt;P&gt;I edited the code, bad copy and paste error.&amp;nbsp; I removed the evaluate.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 15:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307307#M995</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-07-11T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: CONSTRAINT ATTRIBUTE RULE ISSUE</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307311#M996</link>
      <description>&lt;P&gt;Thanks a lot Mike! It works perfectly I'll dig into your code to try to understand it all.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 15:38:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/constraint-attribute-rule-issue/m-p/1307311#M996</guid>
      <dc:creator>EDUARDOARDILARINCON</dc:creator>
      <dc:date>2023-07-11T15:38:06Z</dc:date>
    </item>
  </channel>
</rss>

