<?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: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149092#M6200</link>
    <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;Thanks for taking a look. I'll explore your solution.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To my understanding&amp;nbsp;&lt;SPAN&gt;includeGeometry flag should be set 'true' when you are modifying the features geometry. This concept is outlines in this &lt;A href="https://www.youtube.com/watch?v=UmEh0g2qukk&amp;amp;t=964s" target="_self"&gt;video&lt;/A&gt; at about the 13 min mark.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Again thanks so much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Jake&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2022 14:49:13 GMT</pubDate>
    <dc:creator>Jake_S</dc:creator>
    <dc:date>2022-03-01T14:49:13Z</dc:date>
    <item>
      <title>Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149008#M6196</link>
      <description>&lt;P&gt;When creating an ArcGIS Pro Calculation Attribute Rule that is triggered by an insert or update, if that includes a check of the geometry (&lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt;) the rule does not trigger on insert.&lt;/P&gt;&lt;P&gt;The code below is intended to trigger on insert and update. Applied to the $feature, it updates a field value based on an intersecting feature class. It should, in theory, populate on insert or update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (Equals(Geometry($originalFeature),Geometry($feature))) {
    return $feature.SBPI_ID_NO
}
var parcels = Filter(Intersects(FeatureSetByName($datastore, "Parcel", ["RETIREDBYRECORD", "SBPI_ID_NO"], false), Centroid($feature)),'RETIREDBYRECORD IS NULL')
if (Count(parcels) &amp;gt; 0) {
    var select = first(parcels)
    return select.SBPI_ID_NO;
}
return null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The assumption is that when you create a new feature the &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt; geometry there is NULL (nonexistent) and when compared to $feature, which is assumed to be the new features geometry, the rule will trigger. To clarify, if geometry null/nonexistent is not equal to the new shape geometry the rule should trigger on insert. Because of the design of feature creation in Esri geodatabase (fGDB or eGDB) attribute rules that utilize &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt; on insert do not see a geometry change during creation and do not populate attributes.&lt;/P&gt;&lt;P&gt;This may indicate that during feature creation there is a ‘temporary’ object in which the geodatabase utilizes to calculate the features geometry, then the feature is created permanently in the geodatabase. The assumption is that the rule sees that there is a geometry (temporary object) and that geometry has not changed when creating the permanent geodatabase feature which the user sees.&lt;/P&gt;&lt;P&gt;We had to create a separate attribute rule without &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt; geometry to trigger on insert only. Then utilize the attribute rule below with the &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt; to trigger on update if there is a change to the geometry.&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;LI-CODE lang="javascript"&gt;var parcels = Filter(Intersects(FeatureSetByName($datastore, "Parcel", ["RETIREDBYRECORD", "SBPI_ID_NO"], false), Centroid($feature)),'RETIREDBYRECORD IS NULL')
if (Count(parcels) &amp;gt; 0) {
    var select = first(parcels)
    return select.SBPI_ID_NO;
}
return null&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a common issue? Are we utilizing the &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/" target="_self"&gt;$originalFeature&lt;/A&gt; global incorrectly? Can we confirm that this is in fact how features are created in a Esri Geodatabase?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 09:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149008#M6196</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-03-01T09:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149039#M6199</link>
      <description>&lt;P&gt;I did a quick test, your rule works for me, both in FGDB and SDE.&lt;/P&gt;&lt;P&gt;Possible workarounds:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You can use the &lt;A href="https://developers.arcgis.com/arcade/guide/profiles/#attribute-rule-calculation" target="_blank" rel="noopener"&gt;$editcontext.editType&lt;/A&gt; global&lt;/LI&gt;&lt;LI&gt;The includeGeometry flag of &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyname" target="_blank" rel="noopener"&gt;FeatureSetByName&lt;/A&gt; should probably be true. I'm actually surprised it works when set to false, because (if I understand it correctly) there shouldn't be any geometry for the Intersects...&lt;/LI&gt;&lt;LI&gt;There's nothing wrong with using separate rules for insert and update. Yes, code duplication can be a bit troublesome, but having (different) insert and update procedures in the same rule can also get confusing.&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;// only compare with original geometry when you update, not on insert
if ($editcontext.editType == "UPDATE" &amp;amp;&amp;amp; Equals(Geometry($originalFeature),Geometry($feature))) {
    return $feature.SBPI_ID_NO
}
 // set includeGeometry to true
var parcels = Filter(Intersects(FeatureSetByName($datastore, "Parcel", ["RETIREDBYRECORD", "SBPI_ID_NO"], true), Centroid($feature)),'RETIREDBYRECORD IS NULL')
if (Count(parcels) &amp;gt; 0) {
    var select = first(parcels)
    return select.SBPI_ID_NO;
}
return null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 11:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149039#M6199</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-01T11:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149092#M6200</link>
      <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;Thanks for taking a look. I'll explore your solution.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To my understanding&amp;nbsp;&lt;SPAN&gt;includeGeometry flag should be set 'true' when you are modifying the features geometry. This concept is outlines in this &lt;A href="https://www.youtube.com/watch?v=UmEh0g2qukk&amp;amp;t=964s" target="_self"&gt;video&lt;/A&gt; at about the 13 min mark.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Again thanks so much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Jake&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 14:49:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149092#M6200</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-03-01T14:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149114#M6201</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;Was able to test this and works like a charm. Also tested with&amp;nbsp;&lt;SPAN&gt;includeGeometry flag set to false and executed.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2022 15:26:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149114#M6201</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2022-03-01T15:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149466#M6203</link>
      <description>&lt;P&gt;That's a very helpful video, that I missed completely, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 07:23:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1149466#M6203</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-02T07:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation Attribute Rules that check $originalFeature geometry against newly created features do no trigger on Insert</title>
      <link>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1696714#M7707</link>
      <description>&lt;P&gt;Found this thread when debugging this kind of issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirmed the editType == update workaround works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was curious what $originalFeature actually looked like during an insert, so I logged it like so:&lt;/P&gt;&lt;PRE&gt;return {"errorMessage": Concatenate($originalFeature)}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I then called it with a subset of fields in an applyEdits/ payload:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;=== PAYLOAD ===
{
  "Field_A": foo,
  "Field_B": "bar"&lt;BR /&gt;   // there are other fields on the feature service that I omitted
}&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;And it turns out that $originalFeature looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[
Rule name: $Attribute immediate calc,
Triggering event: Insert,
Class name: $class,
GlobalID: {D2897C65-5D69-4AD1-9654-4B07DDA992D6},
Error number: 0,
Script error: {\"geometry\":{\"x\":...,\"y\":...,\"spatialReference\":{\"latestWkid\":2249,\"wkid\":102686}},\"attributes\":{\"Field_A\":foo,\"Field_B\":bar,\"Field_C\":null}}
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Which means ESRI is doing a few unexpected things on insert:&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;$originalFeature&lt;/STRONG&gt;&lt;STRONG&gt; is not null.&lt;/STRONG&gt; The name "original feature" implies the prior state before an edit. On insert, there is no prior state — the feature doesn't exist yet. A null value would clearly communicate that.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;$originalFeature&lt;/STRONG&gt;&lt;STRONG&gt; is a copy of &lt;/STRONG&gt;&lt;STRONG&gt;$feature&lt;/STRONG&gt;&lt;STRONG&gt;, not the payload we sent.&lt;/STRONG&gt; It includes fields we didn't send, populated with defaults and nulls. This means ESRI is constructing $originalFeature from the hydrated feature, not from the raw input.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;$originalFeature&lt;/STRONG&gt;&lt;STRONG&gt; has the same geometry as &lt;/STRONG&gt;&lt;STRONG&gt;$feature&lt;/STRONG&gt;&lt;STRONG&gt;.&lt;/STRONG&gt; This causes Equals(Geometry($feature), Geometry($originalFeature)) to return true on insert, which is the opposite of what a developer would expect. A common pattern for calculation rules is to skip expensive spatial queries when geometry hasn't changed — this pattern silently breaks on insert because the "unchanged geometry" check passes when there was no previous geometry to compare against.&lt;/LI&gt;&lt;/OL&gt;&lt;DIV&gt;The practical effect is that any calculation rule using the geometry-comparison guard will silently skip its calculation on insert and return whatever placeholder value the client sent, with no error or warning. The lack of ability to log things in attribute rules only exacerbates this issue requiring developers to raise errors instead of doing typical logging, but maybe that's a different thread...&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2026 14:47:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/calculation-attribute-rules-that-check/m-p/1696714#M7707</guid>
      <dc:creator>RobinKurosawa</dc:creator>
      <dc:date>2026-04-16T14:47:32Z</dc:date>
    </item>
  </channel>
</rss>

