<?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 Attribute Rules - Constraint rule for creating point outside a polygon layer in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rules-constraint-rule-for-creating-point/m-p/1155952#M53091</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a simple attribute rule to prevent a user from creating a point &lt;STRONG&gt;outside&lt;/STRONG&gt; a polygon layer.&amp;nbsp; My code is below, when I hit validate it seems to check out but when I try creating points it returns the error even if the point is inside the polygon layer I'm referencing.&amp;nbsp; Any feedback is much appreciated, thanks!&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;// variable for 'AOR' layer&lt;BR /&gt;var aor = FeatureSetByName($datastore, "aor", ['*'], True);&lt;/P&gt;&lt;P&gt;// boolean "if statement" for determining if point intersects the 'aor' layer&lt;BR /&gt;if (Within($feature, aor) == True)&lt;BR /&gt;return True&lt;BR /&gt;else&lt;BR /&gt;return False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 00:28:00 GMT</pubDate>
    <dc:creator>cwlee27</dc:creator>
    <dc:date>2022-03-22T00:28:00Z</dc:date>
    <item>
      <title>Attribute Rules - Constraint rule for creating point outside a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rules-constraint-rule-for-creating-point/m-p/1155952#M53091</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a simple attribute rule to prevent a user from creating a point &lt;STRONG&gt;outside&lt;/STRONG&gt; a polygon layer.&amp;nbsp; My code is below, when I hit validate it seems to check out but when I try creating points it returns the error even if the point is inside the polygon layer I'm referencing.&amp;nbsp; Any feedback is much appreciated, thanks!&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;// variable for 'AOR' layer&lt;BR /&gt;var aor = FeatureSetByName($datastore, "aor", ['*'], True);&lt;/P&gt;&lt;P&gt;// boolean "if statement" for determining if point intersects the 'aor' layer&lt;BR /&gt;if (Within($feature, aor) == True)&lt;BR /&gt;return True&lt;BR /&gt;else&lt;BR /&gt;return False&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 00:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rules-constraint-rule-for-creating-point/m-p/1155952#M53091</guid>
      <dc:creator>cwlee27</dc:creator>
      <dc:date>2022-03-22T00:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute Rules - Constraint rule for creating point outside a polygon layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rules-constraint-rule-for-creating-point/m-p/1155980#M53096</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#within" target="_blank" rel="noopener"&gt;From the documentation:&lt;/A&gt;,&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;This function has 2 signatures:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;UL&gt;&lt;LI&gt;&lt;BLOCKQUOTE&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#within1" target="_blank"&gt;Within(innerGeometry, outerGeometry) -&amp;gt; Boolean&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;/LI&gt;&lt;LI&gt;&lt;BLOCKQUOTE&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/geometry_functions/#within2" target="_blank"&gt;Within(innerGeometry, outerFeatures) -&amp;gt; FeatureSet&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;You use the second version (with a geometry for the inner feature and a feature set for the outer features) and expect a boolean return value, but it actually returns a feature set of polygons. So you have to check if this feature set contains any features.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var aor = FeatureSetByName($datastore, "aor")
return Count(Within($feature, aor)) &amp;gt; 0
// you could also do this
//return First(Within($feature, aor)) != null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 07:30:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rules-constraint-rule-for-creating-point/m-p/1155980#M53096</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-22T07:30:51Z</dc:date>
    </item>
  </channel>
</rss>

