<?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 Inconsistent functioning of Arcade Script between Calculate Field and Attribute Rule implementation in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1536811#M88098</link>
    <description>&lt;P&gt;Greetings.&amp;nbsp; I'm trying to create an attribute rule to automatically name objects when they are created.&amp;nbsp; Our naming convention requires using an asset id grid where the grid name is incorporated into the asset name.&amp;nbsp; I written an Arcade Expression that works when calculating a field.&amp;nbsp; When I then try to use that same expression as code in an attribute rule, I get a 002717 error indicating an unexpected null value.&amp;nbsp; I tried submitting or Arcade expressions that are much simpler and also get the same error.&amp;nbsp; I don't understand why the code runs without issue in the calculate field tool, but kicks back an error when being used as an attribute rule.&amp;nbsp; I understand I am not adding the code properly in the forum, I cannot seem to find the right way to add it.&amp;nbsp; I'm adding the code in the text below.&lt;/P&gt;&lt;P&gt;var agrid = (FeatureSetByName($datastore, 'DBO.CAIDGD', ['Utility_ID']));&lt;/P&gt;&lt;P&gt;var gridid = First(Intersects(agrid, $feature));&lt;/P&gt;&lt;P&gt;return gridid.Utility_ID;&lt;/P&gt;&lt;P&gt;The above three lines of code work in the calculate field, but do not pass as an attribute rule.&amp;nbsp; The above code is simplified in a much larger script as a single line of code below.&lt;/P&gt;&lt;P&gt;var currentValue = First(Intersects(FeatureSetByName($datastore, 'DBO.CAIDGD',['Utility_ID']),$feature)).Utility_ID;&lt;/P&gt;&lt;P&gt;In the larger script, the above code is the line identified with the 002717 error when I try to use the script in an attribute rule calculation rule.&lt;/P&gt;&lt;P&gt;Thanks all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 13:17:11 GMT</pubDate>
    <dc:creator>PCWRGIS</dc:creator>
    <dc:date>2024-09-10T13:17:11Z</dc:date>
    <item>
      <title>Inconsistent functioning of Arcade Script between Calculate Field and Attribute Rule implementation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1536811#M88098</link>
      <description>&lt;P&gt;Greetings.&amp;nbsp; I'm trying to create an attribute rule to automatically name objects when they are created.&amp;nbsp; Our naming convention requires using an asset id grid where the grid name is incorporated into the asset name.&amp;nbsp; I written an Arcade Expression that works when calculating a field.&amp;nbsp; When I then try to use that same expression as code in an attribute rule, I get a 002717 error indicating an unexpected null value.&amp;nbsp; I tried submitting or Arcade expressions that are much simpler and also get the same error.&amp;nbsp; I don't understand why the code runs without issue in the calculate field tool, but kicks back an error when being used as an attribute rule.&amp;nbsp; I understand I am not adding the code properly in the forum, I cannot seem to find the right way to add it.&amp;nbsp; I'm adding the code in the text below.&lt;/P&gt;&lt;P&gt;var agrid = (FeatureSetByName($datastore, 'DBO.CAIDGD', ['Utility_ID']));&lt;/P&gt;&lt;P&gt;var gridid = First(Intersects(agrid, $feature));&lt;/P&gt;&lt;P&gt;return gridid.Utility_ID;&lt;/P&gt;&lt;P&gt;The above three lines of code work in the calculate field, but do not pass as an attribute rule.&amp;nbsp; The above code is simplified in a much larger script as a single line of code below.&lt;/P&gt;&lt;P&gt;var currentValue = First(Intersects(FeatureSetByName($datastore, 'DBO.CAIDGD',['Utility_ID']),$feature)).Utility_ID;&lt;/P&gt;&lt;P&gt;In the larger script, the above code is the line identified with the 002717 error when I try to use the script in an attribute rule calculation rule.&lt;/P&gt;&lt;P&gt;Thanks all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 13:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1536811#M88098</guid>
      <dc:creator>PCWRGIS</dc:creator>
      <dc:date>2024-09-10T13:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent functioning of Arcade Script between Calculate Field and Attribute Rule implementation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1536844#M88099</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/701541"&gt;@PCWRGIS&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;For it to work you need to have check for a null return on your FeatureSetByName before passing into First and Intersects otherwise the code will not validate in an attribute rule.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Give this a try.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var agrid = (FeatureSetByName($datastore, 'DBO.CAIDGD', ['Utility_ID']));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;if (count(agrid) == 0) return;&lt;/P&gt;&lt;P&gt;var gridid = First(Intersects(agrid, $feature));&lt;/P&gt;&lt;P&gt;return gridid.Utility_ID;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 14:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1536844#M88099</guid>
      <dc:creator>rlyding</dc:creator>
      <dc:date>2024-09-10T14:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent functioning of Arcade Script between Calculate Field and Attribute Rule implementation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1537005#M88106</link>
      <description>Thank you for your comment. That specific syntax is not working on my end. I will see if I can modify this to get it to work.&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Sep 2024 18:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1537005#M88106</guid>
      <dc:creator>PCWRGIS</dc:creator>
      <dc:date>2024-09-10T18:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent functioning of Arcade Script between Calculate Field and Attribute Rule implementation</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1537500#M88159</link>
      <description>&lt;P&gt;Here is another example. If not you may want to try and make a post in the ESRI community specifically used for Attribute Rule related questions.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Create feature set to the intersecting class
var intersecting_featset = FeatureSetByName($datastore, 'DBO.CAIDGD', ['Utility_ID'], false)
// Intersecting the feature with the feature set and retrieve the first feature
var intersected_feature = First(Intersects(intersecting_featset, $feature));

// Check to make sure there was an intersected feature, if not, return
if (IsEmpty(intersected_feature) || intersected_feature == null)
{
return null;
}
return intersected_feature.Utility_ID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 19:26:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/inconsistent-functioning-of-arcade-script-between/m-p/1537500#M88159</guid>
      <dc:creator>rlyding</dc:creator>
      <dc:date>2024-09-11T19:26:10Z</dc:date>
    </item>
  </channel>
</rss>

