<?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 rule not working in 3.1 in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1282266#M68341</link>
    <description>&lt;P&gt;I just encountered a similar issue. The Arcade syntax was correct and now it was throwing an error. Esri needs to check their syntax-checking software as I believe there is an issue with the update.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 13:12:14 GMT</pubDate>
    <dc:creator>James_Whitacre_PGC</dc:creator>
    <dc:date>2023-04-25T13:12:14Z</dc:date>
    <item>
      <title>Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261767#M65950</link>
      <description>&lt;P&gt;This attribute rule works in ArcGIS Pro 3.0 but when I upgraded to 3.1 yesterday it stopped working.&amp;nbsp; Can anyone tell me why?&amp;nbsp; What changed from 3.0 to 3.1? I'm not very knowledgeable with Arcade!&amp;nbsp; I am not able to edit the layer at all with this attribute rule turned on.&amp;nbsp; &amp;nbsp;Other attribute rules still work.&amp;nbsp; Here is the error message and the code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahIerley1_0-1677334472789.png" style="width: 281px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63725i86572FEB329B57BD/image-dimensions/281x153?v=v2" width="281" height="153" role="button" title="SarahIerley1_0-1677334472789.png" alt="SarahIerley1_0-1677334472789.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;// This rule will calculate the left and right municipality for a road.&lt;BR /&gt;// It determines if the road is completely within a intersectingArea or falls on the edge of a intersectingArea and updates the appropriate values on the road&lt;BR /&gt;// Define the Road Centerline fields&lt;BR /&gt;var jurisleft_field = "L_JURISDIC";&lt;BR /&gt;var jurisright_field = "R_JURISDIC";&lt;BR /&gt;// Define the Geopolitical Areas fields&lt;BR /&gt;var jurisname_field = "JURISD";&lt;BR /&gt;// Get the intersecting Geopolictical Areas&lt;BR /&gt;var intersectingAreas = Intersects(FeatureSetByName($datastore, "PublicSafetyGIS_Data.PUBLICSAFETYGIS.Test_Jurisdictions", [jurisname_field], true), $feature)&lt;BR /&gt;// This function will convert a polygon geometry to a polyline&lt;BR /&gt;function polygonToPolyline(p) {&lt;BR /&gt;var json = Dictionary(Text(p));&lt;BR /&gt;var polylineJSON = {&lt;BR /&gt;"paths": json["rings"],&lt;BR /&gt;"spatialReference": json["spatialReference"]&lt;BR /&gt;};&lt;BR /&gt;return Polyline(polylineJSON)&lt;BR /&gt;}&lt;BR /&gt;// Test if the road falls completely within a area and does not overlap any of the area's outline&lt;BR /&gt;// If it does update the left and right value to be equal to the area's value&lt;BR /&gt;var isWithin = false;&lt;BR /&gt;var partialOverlap = [];&lt;BR /&gt;for (var intersectingArea in intersectingAreas) {&lt;BR /&gt;if (Within($feature, intersectingArea)) {&lt;BR /&gt;var line = polygonToPolyline(Geometry(intersectingArea));&lt;BR /&gt;if (!Overlaps($feature, line)) {&lt;BR /&gt;var jurisleft = intersectingArea[jurisname_field];&lt;BR /&gt;var jurisright = intersectingArea[jurisname_field];&lt;BR /&gt;isWithin = true;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;// Store any boundaries the line is partially within (overlaps some of the polygons intersectingArea)&lt;BR /&gt;else {&lt;BR /&gt;Push(partialOverlap, intersectingArea);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;// If the road does not fall within a area, attempt to find any areas that it overlaps the outline&lt;BR /&gt;// Then test if the polygon is on the right or left side of the line and update the right or left value&lt;BR /&gt;if (!isWithin) {&lt;BR /&gt;var isRightValue = false;&lt;BR /&gt;var isLeftValue = false;&lt;BR /&gt;for (var intersectingArea in intersectingAreas) {&lt;BR /&gt;var line = polygonToPolyline(Geometry(intersectingArea));&lt;BR /&gt;if (Within($feature, line)) {&lt;BR /&gt;// Offset the geometry to the right and test if it intersects the intersectingArea&lt;BR /&gt;var offset_geometry = Offset($feature, 5);&lt;BR /&gt;if (Intersects(offset_geometry, intersectingArea)) {&lt;BR /&gt;var jurisright = intersectingArea[jurisname_field];&lt;BR /&gt;isRightValue = true;&lt;BR /&gt;}&lt;BR /&gt;// Offset the geometry to the left and test if it intersects the intersectingArea&lt;BR /&gt;offset_geometry = Offset($feature, -5);&lt;BR /&gt;if (Intersects(offset_geometry, intersectingArea)) {&lt;BR /&gt;var jurisleft = intersectingArea[jurisname_field];&lt;BR /&gt;isLeftValue = true;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;// If either the left or right value is not set we will loop through the partially within&lt;BR /&gt;if (isLeftValue || isRightValue) {&lt;BR /&gt;for (var i in partialOverlap) {&lt;BR /&gt;var intersectingArea = partialOverlap[i];&lt;BR /&gt;var line = polygonToPolyline(Geometry(intersectingArea));&lt;BR /&gt;// Get the portion of the road that overlaps the polygon intersectingArea&lt;BR /&gt;var intersection_geometry = Intersection($feature, line);&lt;BR /&gt;// Offset this portion of the road to the right and test if it intersects the intersectingArea&lt;BR /&gt;var offset_geometry = Offset(intersection_geometry, 5);&lt;BR /&gt;if (Intersects(offset_geometry, intersectingArea) &amp;amp;&amp;amp; !isRightValue) {&lt;BR /&gt;var jurisright = intersectingArea[jurisname_field];&lt;BR /&gt;}&lt;BR /&gt;// Offset this portion of the road to the left and test if it intersects the intersectingArea&lt;BR /&gt;offset_geometry = Offset(intersection_geometry, -5);&lt;BR /&gt;if (Intersects(offset_geometry, intersectingArea) &amp;amp;&amp;amp; !isLeftValue) {&lt;BR /&gt;var jurisleft = intersectingArea[jurisname_field];&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return {&lt;BR /&gt;"result": {&lt;BR /&gt;"attributes":&lt;BR /&gt;Dictionary(&lt;BR /&gt;jurisleft_field, jurisleft,&lt;BR /&gt;jurisright_field, jurisright&lt;BR /&gt;)&lt;BR /&gt;}&lt;BR /&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;</description>
      <pubDate>Sat, 25 Feb 2023 14:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261767#M65950</guid>
      <dc:creator>SarahIerley1</dc:creator>
      <dc:date>2023-02-25T14:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261773#M65953</link>
      <description>&lt;P&gt;Maybe try re-posting in Attribute Rule questions as well&amp;nbsp;&lt;A href="https://community.esri.com/t5/attribute-rules-questions/bd-p/attribute-rules-questions" target="_blank"&gt;https://community.esri.com/t5/attribute-rules-questions/bd-p/attribute-rules-questions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Feb 2023 15:39:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261773#M65953</guid>
      <dc:creator>KoryKramer</dc:creator>
      <dc:date>2023-02-25T15:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261855#M65969</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/443905"&gt;@SarahIerley1&lt;/a&gt;&amp;nbsp;Here is some info that I got from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346994"&gt;@HusseinNasser2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;var isRightValue = false;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var isLeftValue = false;&lt;BR /&gt;must be moved outside the if &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It could be a bug in the script we were not reporting correctly before and now we are.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Could you modify the script?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Feb 2023 19:16:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1261855#M65969</guid>
      <dc:creator>KoryKramer</dc:creator>
      <dc:date>2023-02-26T19:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1282266#M68341</link>
      <description>&lt;P&gt;I just encountered a similar issue. The Arcade syntax was correct and now it was throwing an error. Esri needs to check their syntax-checking software as I believe there is an issue with the update.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 13:12:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1282266#M68341</guid>
      <dc:creator>James_Whitacre_PGC</dc:creator>
      <dc:date>2023-04-25T13:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285735#M68772</link>
      <description>&lt;P&gt;So are you saying that the acceptable syntax for Arcade has changed? All my attribute rules for ADMS have broken at Pro 3.1.1&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 16:31:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285735#M68772</guid>
      <dc:creator>JamesBurton1</dc:creator>
      <dc:date>2023-05-04T16:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285752#M68774</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/127924"&gt;@JamesBurton1&lt;/a&gt;&amp;nbsp;I was NOT making the claim that the Arcade syntax changed, but rather that the software that checks if the syntax is correct changed (i.e. the &lt;A href="https://en.wikipedia.org/wiki/Lint_(software)" target="_self"&gt;linter&lt;/A&gt; software).&amp;nbsp;I suppose It is possible that the syntax changed, but in my case, I could not identify anything in the documentation that indicated the syntax changed for the Arcade code we were using. It would be great to get an Esri staff person to comment on this issue. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 17:00:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285752#M68774</guid>
      <dc:creator>James_Whitacre_PGC</dc:creator>
      <dc:date>2023-05-04T17:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285798#M68780</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;let me add context to why you are getting this object not found error at least in this particular case. Simplifying the script you have to the following&lt;/P&gt;&lt;P&gt;there is a condition that when met, you define a variable inside the if block and set it to a value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Later outside the scope of the if block you do another if and use that variable. This is variable scoping, the variable isLeft will only be defined if the first condition is met&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HusseinNasser2_0-1683222306228.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69885iD29B083EA2764D0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HusseinNasser2_0-1683222306228.png" alt="HusseinNasser2_0-1683222306228.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if the first condition was not met, the variable isLeft will never be defined and the second if will fail with isLeft object is error. This is because Arcade has inherited its behavior from Javascript.&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="HusseinNasser2_1-1683222568886.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69888i28EE7CE904D004D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HusseinNasser2_1-1683222568886.png" alt="HusseinNasser2_1-1683222568886.png" /&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;Why did this work in 3.0 and not in 3.1? Well I could argue that the script may also fail in 3.0 or any release as well if $feature happened to not satisfy the first condition which leads to the variables to not getting defined.&amp;nbsp;I think you can reproduce this in 3.0 by creating a feature outside&amp;nbsp;&lt;SPAN&gt;Test_Jurisdictions.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So the real solution for more predictable script is to define the scripts outside the scope. that is move isLeft and IsRight so they are at global scope if you are planning to use them across the script.&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 there are any other cases where the script fail but the syntax looks correct please post it in the this thread and we will take a look.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Hope that clarifies it. Thank you and apologies for the late reply.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 18:17:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285798#M68780</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2023-05-04T18:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285880#M68789</link>
      <description>&lt;P&gt;I'm having trouble with this attribute rule that used to work just fine. It seems the syntax to call a field from a variable is not working anymore. E.g. layer['zipcode']&lt;/P&gt;&lt;P&gt;Error is attached. Here is the rule:&lt;/P&gt;&lt;P&gt;var zip = FeatureSetByName($datastore, 'ZipCodes', ['ZIP5'], true);&lt;BR /&gt;var intersectLayer = Intersects(zip, Geometry($feature));&lt;BR /&gt;if (Count(intersectLayer) &amp;gt; 0) {&lt;BR /&gt;var layer = First(intersectLayer);&lt;BR /&gt;return layer['zipcode'];&lt;BR /&gt;} else {&lt;BR /&gt;return null;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 20:24:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285880#M68789</guid>
      <dc:creator>JamesBurton1</dc:creator>
      <dc:date>2023-05-04T20:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285924#M68797</link>
      <description>&lt;P&gt;Hey&amp;nbsp; James&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FeatureSetByName you are only asking for the ZIP5 to be returned, but then you are attempting to access. the zipcode field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To fix this add the zipcode field.&lt;/P&gt;&lt;P&gt;See if that helps. That is something we fixed in 3.1 where in some cases prior releases we were fetching all fields regardless of what you asked it to, which is why you script worked before but no longer does.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var zip = FeatureSetByName($datastore, 'ZipCodes', ['ZIP5', 'zipcode'], true);
var intersectLayer = Intersects(zip, Geometry($feature));
if (Count(intersectLayer) &amp;gt; 0) {
var layer = First(intersectLayer);
return layer['zipcode'];
} else {
return null;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 22:18:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1285924#M68797</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2023-05-04T22:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule not working in 3.1</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1332089#M73410</link>
      <description>&lt;P&gt;Helo,&lt;/P&gt;&lt;P&gt;I'm also having problems with calculations of attribute rules that were working, including in published services, and stopped working.&lt;BR /&gt;In my case, no error message appears, it is simply as if the rule was not fired!&lt;BR /&gt;This happens when I make edits, when creating new features the rules are being applied.&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;var pol_bairro = FeatureSetByName($datastore, "gisdb.cadtec.Bairros")&lt;BR /&gt;var i_pol_bairro = First(Intersects(pol_bairro, Centroid($feature)))&lt;BR /&gt;if(i_pol_bairro == null) {return null}&lt;BR /&gt;return i_pol_bairro.Bairro&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Does anyone have any idea why this behavior occurs, or how I can track whether the function is working?&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 18:32:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-not-working-in-3-1/m-p/1332089#M73410</guid>
      <dc:creator>Arueira</dc:creator>
      <dc:date>2023-09-25T18:32:01Z</dc:date>
    </item>
  </channel>
</rss>

