<?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: Unexpected Null error only when trying to save rule in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309247#M1007</link>
    <description>Definitely need to pass true into FSByName for the geometry parameter so intersect works.&lt;BR /&gt;&lt;BR /&gt;Also, there is a chance that you intersect nothing, so you need to check if the result of first is null and exit differently.&lt;BR /&gt;</description>
    <pubDate>Tue, 18 Jul 2023 19:12:30 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2023-07-18T19:12:30Z</dc:date>
    <item>
      <title>Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309237#M1006</link>
      <description>&lt;P&gt;I spoke with &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/346994"&gt;@HusseinNasser2&lt;/a&gt;&amp;nbsp;at the conference about an issue with my Arcade expression. Using his sample, I'm trying to recreate my rule, starting with a simple intersect. Ultimately, this rule will include intersections with multiple layers, so I'm modifying the sample to use a results dictionary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running into a problem when I try to save the attribute rule. It validates fine when I'm in the Expression editor, and console messages show a valid result. However, when I click 'Save', I'm presented with the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR 002717: Invalid Arcade expression, Arcade error: Unexpected null, Script line: 8&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fs = FeatureSetByName($datastore,"City_Limits",["TOWN"],false);
var intFs = Intersects(fs, Geometry($feature));
var cityLimit = First(intFs)

return {
   'result':{
      'attributes':{
         'MUNICIPALITY':cityLimit.TOWN
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I said, the Expression validates normally in the Editor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CraigCarsley_0-1689706188920.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75663i448DE298585E80B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CraigCarsley_0-1689706188920.png" alt="CraigCarsley_0-1689706188920.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and the console message &amp;gt;&amp;gt; console(cityLimit.TOWN) yields:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CraigCarsley_1-1689706244453.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75664iE7D47A66C34871FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CraigCarsley_1-1689706244453.png" alt="CraigCarsley_1-1689706244453.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I print the entire results dictionary to the console, I get this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{"result":{"attributes":{"MUNICIPALITY":"Omaha"}}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why I'm having a problem here?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 18:54:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309237#M1006</guid>
      <dc:creator>CraigCarsley</dc:creator>
      <dc:date>2023-07-18T18:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309247#M1007</link>
      <description>Definitely need to pass true into FSByName for the geometry parameter so intersect works.&lt;BR /&gt;&lt;BR /&gt;Also, there is a chance that you intersect nothing, so you need to check if the result of first is null and exit differently.&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jul 2023 19:12:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309247#M1007</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-07-18T19:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309278#M1008</link>
      <description>&lt;P&gt;Thanks for the swift reply, Mike.&lt;/P&gt;&lt;P&gt;I thought the same thing about passing 'true' into FSByName, but Hussein said it's not needed because I'm not actually doing anything with the geometry. However, I did try doing that just to see if it made a difference. It will return a geometry value, but it doesn't resolve the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a few different ways to check if the result is null, but I ultimately realized the resulting feature set is not the issue. The issue occurs only when I try to access the field name TOWN in the result. If I set the result to be &lt;STRONG&gt;'MUNICIPALITY': cityLimits&lt;/STRONG&gt;&amp;nbsp;(removing .TOWN), the expression still validates and I am actually able to save the rule. It's only a problem when trying to access the TOWN attribute in the City Limits fc.&lt;/P&gt;&lt;P&gt;Just to be on the safe side, I created a brand new feature class in a file geodatabase and copied the features manually into it so there wouldn't be any chance of overhead or corruption. The layer has a total of 8 features, none of which have a null TOWN value:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CraigCarsley_0-1689713495760.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75672i86540E2ECF6FC101/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CraigCarsley_0-1689713495760.png" alt="CraigCarsley_0-1689713495760.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 20:53:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309278#M1008</guid>
      <dc:creator>CraigCarsley</dc:creator>
      <dc:date>2023-07-18T20:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309293#M1009</link>
      <description>&lt;P&gt;Correct, if you were using the geometry on the citylimit feature then you would want to return geometry.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you need to guard against null. As&amp;nbsp; First() might not return any result.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fs = FeatureSetByName($datastore,"City_Limits",["TOWN"],false);
var intFs = Intersects(fs, Geometry($feature));
var cityLimit = First(intFs)

//if the cityLimit feature is null do an early exit. 
if (cityLimit == null)  return;

return {
   'result':{
      'attributes':{
         'MUNICIPALITY':cityLimit.TOWN
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 21:33:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309293#M1009</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2023-07-18T21:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309309#M1010</link>
      <description>&lt;P&gt;Thanks Nasser. I guarded against null, and I was able to save. I'm not getting any result from the attribute rule though. When I add a point, the MUNICIPALITY value remains null. It's as if the action of creating a point is getting a null cityLimit and then returning empty.&lt;/P&gt;&lt;P&gt;Here's my rule as it stands now:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var fs = FeatureSetByName($datastore,"City_Limits",["TOWN"],false);
var intFs = Intersects(fs, Geometry($feature));
var cityLimit = First(intFs)
if (cityLimit == null) return;

return {
   'result':{
      'attributes':{
         'MUNICIPALITY':cityLimit.TOWN
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CraigCarsley_0-1689717712024.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75675i3122EA486D3F96FD/image-size/large?v=v2&amp;amp;px=999" role="button" title="CraigCarsley_0-1689717712024.png" alt="CraigCarsley_0-1689717712024.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CraigCarsley_1-1689717788120.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75676i9BC4D01D57160A76/image-size/large?v=v2&amp;amp;px=999" role="button" title="CraigCarsley_1-1689717788120.png" alt="CraigCarsley_1-1689717788120.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 22:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309309#M1010</guid>
      <dc:creator>CraigCarsley</dc:creator>
      <dc:date>2023-07-18T22:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309447#M1017</link>
      <description>&lt;P&gt;Can you post your sample GDB for us to test out?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 11:24:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309447#M1017</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-07-19T11:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309449#M1018</link>
      <description>&lt;P&gt;Also, on your screen shot, the rules is disabled, make sure to enable it&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 11:25:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1309449#M1018</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-07-19T11:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1310094#M1021</link>
      <description>&lt;P&gt;How embarrassing for me. That was the problem.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks Mike&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 16:05:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1310094#M1021</guid>
      <dc:creator>CraigCarsley</dc:creator>
      <dc:date>2023-07-20T16:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1326208#M1105</link>
      <description>&lt;P&gt;Hello Nasser,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to fix an attribute rule I had working in arcpro 3.0 that is now not working in 3.1.1&lt;/P&gt;&lt;P&gt;The rule is essentially the same as Craigs, where I have a point feature class and a poly feature class and I want to return attributes from the poly feature class to the point feature class when a point is created within a poly.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;///load the Areas poylgon class
var PhysProv = FeatureSetByName($datastore, "intermtnwest.sde.Provinces_Surficial", ["provprefix"], true)


//intersect the areas with the inserted/edited feature
var inter = Intersects(PhysProv, Geometry($feature));
var interfirst = First(inter)

// if feature is not in any area, early exit
if(interfirst == null) return;

return {
   'result':{
      'attributes':{
         'provprefix':interfirst.provprefix
      }
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The problem that I am having is that in some areas of the polygons when I create points the return value from my rule is null when it should return a value. There are several polygons that do this and the pattern seems random. I have deleted the polys and re-created them with the same result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="katherinealexander_USGS_0-1694050361598.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80042iFED3A890F8C4D6D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="katherinealexander_USGS_0-1694050361598.png" alt="katherinealexander_USGS_0-1694050361598.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is one example where the point near the bottom of the poly calculated correctly and the point at the top comes out as null.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be very greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 01:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1326208#M1105</guid>
      <dc:creator>katherinealexander_USGS</dc:creator>
      <dc:date>2023-09-07T01:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1326966#M1113</link>
      <description>&lt;P&gt;hey Katherine&lt;/P&gt;&lt;P&gt;i see this is a direct connect sde connection,&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you try on a filegdb and see if you see the same behavior?&lt;/P&gt;&lt;P&gt;and also is it possible to send a data (with just one "bad" polygon) that reproduces feel free to take any fields/ data that is not relevant.&lt;/P&gt;&lt;P&gt;your code looks correct so my guess it might be the spatial reference ..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 19:30:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1326966#M1113</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2023-09-08T19:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Null error only when trying to save rule</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1334247#M1136</link>
      <description>&lt;P&gt;Hi again,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I exported one of my problem polygons to a filegdb like you suggested and I am not getting the error that I do when I'm in the enterprise environment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I attached a zip folder that contains the filegdb with all the elements to make the attribute rules work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for any insight you might have.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 18:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/unexpected-null-error-only-when-trying-to-save/m-p/1334247#M1136</guid>
      <dc:creator>katherinealexander_USGS</dc:creator>
      <dc:date>2023-10-02T18:28:59Z</dc:date>
    </item>
  </channel>
</rss>

