<?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: IF statement for a constraint in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090250#M177</link>
    <description>&lt;P&gt;Probably you missed the curly brackets when copying the code, but still:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id==null) {
  return true;
}
return false; &lt;/LI-CODE&gt;&lt;P&gt;The problem with this code is the following: If you are inserting a street with street_status 2, it will return false, because you only check for street_status 1 and return false otherwise. This should work in those cases:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id!=null) {
  return false;
}
return true;&lt;/LI-CODE&gt;&lt;P&gt;This defaults to returning true and only blocks the insert/edit on the combination you don't want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other things to check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;As Chris said: Is street_status numeric?&lt;/LI&gt;&lt;LI&gt;Instead of the null check, you could try IsEmpty($feature.street_id)&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Thu, 19 Aug 2021 05:25:39 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-08-19T05:25:39Z</dc:date>
    <item>
      <title>IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090101#M174</link>
      <description>&lt;P&gt;Im trying to create a constraint where&amp;nbsp;if street_status=1 then the street_id must be null.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this statement but I get an error message each time I try to update&amp;nbsp;street_status or street_id&lt;/P&gt;&lt;P&gt;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id==null)&amp;nbsp;&lt;/P&gt;&lt;P&gt;return true;&lt;/P&gt;&lt;P&gt;else&amp;nbsp;&lt;/P&gt;&lt;P&gt;return false;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 19:09:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090101#M174</guid>
      <dc:creator>V1212</dc:creator>
      <dc:date>2021-08-18T19:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090176#M175</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;What error are you getting? Is street_status a numeric field?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 22:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090176#M175</guid>
      <dc:creator>ChrisGAEG</dc:creator>
      <dc:date>2021-08-18T22:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090250#M177</link>
      <description>&lt;P&gt;Probably you missed the curly brackets when copying the code, but still:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id==null) {
  return true;
}
return false; &lt;/LI-CODE&gt;&lt;P&gt;The problem with this code is the following: If you are inserting a street with street_status 2, it will return false, because you only check for street_status 1 and return false otherwise. This should work in those cases:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id!=null) {
  return false;
}
return true;&lt;/LI-CODE&gt;&lt;P&gt;This defaults to returning true and only blocks the insert/edit on the combination you don't want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other things to check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;As Chris said: Is street_status numeric?&lt;/LI&gt;&lt;LI&gt;Instead of the null check, you could try IsEmpty($feature.street_id)&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Thu, 19 Aug 2021 05:25:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1090250#M177</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-08-19T05:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1091503#M187</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The constraint rule does the following: Only allow features to be edited/created when their status is 1 and the street_id is null. Any other value, fail the edit which is what you are experiencing.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might want to define your logic more explicitly. I'm assuming you want to ONLY fail when the status is 1 AND the street_Id is not NULL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can specify your logic this way.&amp;nbsp;&amp;nbsp;&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;if ($feature.street_status==1 &amp;amp;&amp;amp; $feature.street_id != null) 

return false;

else 

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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="constr.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/21466i5268563505B33866/image-size/medium?v=v2&amp;amp;px=400" role="button" title="constr.gif" alt="constr.gif" /&gt;&lt;/span&gt;&lt;/P&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; &lt;/P&gt;</description>
      <pubDate>Mon, 23 Aug 2021 23:40:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1091503#M187</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2021-08-23T23:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1091882#M192</link>
      <description>&lt;P&gt;Im getting the constraint popup when I change the street_status to any value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 19:31:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1091882#M192</guid>
      <dc:creator>V1212</dc:creator>
      <dc:date>2021-08-27T19:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement for a constraint</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1093253#M200</link>
      <description>&lt;P&gt;Thanks for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't realized that&amp;nbsp;&lt;SPAN&gt;street_status wasn't numeric.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 19:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/if-statement-for-a-constraint/m-p/1093253#M200</guid>
      <dc:creator>V1212</dc:creator>
      <dc:date>2021-08-27T19:31:23Z</dc:date>
    </item>
  </channel>
</rss>

