<?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: ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207721#M65435</link>
    <description>&lt;P&gt;This is a way you could handle a split.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Attribute Rule
// field: ParcelID
// triggers: Insert
// Exclude from Application Evaluation

// An Insert can be a "normal" insert or a Split operation

var id = $feature.ParcelID
var gid = $feature.GlobalID

// no ParcelID -&amp;gt; normal insert, create and return a new ParcelID
if(id == null) {
    var new_id = NextSequenceValue("SequenceParcelID")
    return new_id
}

var other_parcels = Filter($featureset, "ParcelID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt; AND GlobalID &amp;lt;&amp;gt; @gid")

// no other parcels with the same ParcelID -&amp;gt; normal Insert.
if(Count(other_parcels) == 0) {
    return id
}

// else, it's a Split operation
// create and fill an array of updates to the other split parts
var updates = []
var i = 2  // this $feature gets id 1
for(var op in other_parcels) {
    var new_id = op.ParcelID + "_" + Text(i++, "00")
    Push(updates, {globalID: op.GlobalID, attributes: {ParcelID: new_id}})
}
return {
    result: $feature.ParcelID + "_01",  // the new ParcelID of this feature
    edit: [{className: "TestPolygons", updates: updates}]  // apply the edits   to the other split parts  !!! CHANGE THE CLASSNAME !!!
}&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1661872188138.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49822iB8502B4013FB23F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1661872188138.png" alt="JohannesLindner_1-1661872188138.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="JohannesLindner_2-1661872246627.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49823i13F60FF53739E63C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1661872246627.png" alt="JohannesLindner_2-1661872246627.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have looked for a way to detect merges, but I haven't fond one, yet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You could just add this Attribute Rule:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Attribute Rule
// field: ParcelID
// triggers: Update

var id = $feature.ParcelID
if(id == null) {
    var new_id = NextSequenceValue("SequenceParcelID")
    return new_id
}
return id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And then delete the ParcelID in the Merge dialog:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_3-1661872377519.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49825i49976FB0C7161C0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_3-1661872377519.png" alt="JohannesLindner_3-1661872377519.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_4-1661872386738.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49826i87002DC2E4836CF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_4-1661872386738.png" alt="JohannesLindner_4-1661872386738.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, 30 Aug 2022 15:16:44 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-08-30T15:16:44Z</dc:date>
    <item>
      <title>ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207078#M65419</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, I want to implement immediate attribute rule on&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;$editContext.&lt;/SPAN&gt;&lt;SPAN&gt;editType for "UPDATE" to generate a new parcel id on splitting of polygons and merging of polygons but not able to find split &amp;amp; merge event in ArcGIS Aracade Expression. I found that Cut(polylineOrPolygon, cutter)&amp;nbsp; is available for ArcCade Expression. Please if anyone have any idea about ... please share.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 06:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207078#M65419</guid>
      <dc:creator>SU00861536</dc:creator>
      <dc:date>2022-08-29T06:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207142#M65421</link>
      <description>&lt;P&gt;The Cut() function is for cutting geometries, not for detecting cuts.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$editcontext.editType only returns "INSERT", "UPDATE" or "DELETE". There is no way to trigger the rule only on a merge or cut operation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A possible workaround could be to detect changes in the geometry:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Attribute rule to calculate parcel id
// triggers: insert, update

var geometry_changed = $editcontext.editType == "UPDATE" &amp;amp;&amp;amp; !Equals(Geometry($feature), Geometry($originalfeature))
if($editcontext.editType == "INSERT" || geometry_changed) {
    var new_id = ...
    return new_id
}
// If we land here, the feature got updated, but the geometry didn't change
return $feature.ParcelID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this will calculate a new ID everytime you edit the geometry. So it will only work if cutting and merging are the only geometry edits you do.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 10:18:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207142#M65421</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-29T10:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207564#M65429</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am planning to generate new id on the basis of split (UPDATE TRIGGER)&amp;nbsp; assigning new id using the parent id eg: Polygon ID : 0070 -- Splitted in to two parts so splitted polygon id will be -- 1) 0070_01 and 2) 0070_02.&lt;/P&gt;&lt;P&gt;Same for merging the two polygons 1) 0070_01 2) 0070_02 and assign new id 0071( merged polygon).&lt;/P&gt;&lt;P&gt;I want to find the Split or Merge operation in Arcade expression.&lt;/P&gt;&lt;P&gt;Kindly share some idea to differentiate in Split &amp;amp; Merge operation at Arcade ( already tried Geometry equal &amp;amp; object id equal)&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 06:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207564#M65429</guid>
      <dc:creator>SU00861536</dc:creator>
      <dc:date>2022-08-30T06:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207721#M65435</link>
      <description>&lt;P&gt;This is a way you could handle a split.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Attribute Rule
// field: ParcelID
// triggers: Insert
// Exclude from Application Evaluation

// An Insert can be a "normal" insert or a Split operation

var id = $feature.ParcelID
var gid = $feature.GlobalID

// no ParcelID -&amp;gt; normal insert, create and return a new ParcelID
if(id == null) {
    var new_id = NextSequenceValue("SequenceParcelID")
    return new_id
}

var other_parcels = Filter($featureset, "ParcelID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/354972"&gt;@ID&lt;/a&gt; AND GlobalID &amp;lt;&amp;gt; @gid")

// no other parcels with the same ParcelID -&amp;gt; normal Insert.
if(Count(other_parcels) == 0) {
    return id
}

// else, it's a Split operation
// create and fill an array of updates to the other split parts
var updates = []
var i = 2  // this $feature gets id 1
for(var op in other_parcels) {
    var new_id = op.ParcelID + "_" + Text(i++, "00")
    Push(updates, {globalID: op.GlobalID, attributes: {ParcelID: new_id}})
}
return {
    result: $feature.ParcelID + "_01",  // the new ParcelID of this feature
    edit: [{className: "TestPolygons", updates: updates}]  // apply the edits   to the other split parts  !!! CHANGE THE CLASSNAME !!!
}&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1661872188138.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49822iB8502B4013FB23F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1661872188138.png" alt="JohannesLindner_1-1661872188138.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="JohannesLindner_2-1661872246627.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49823i13F60FF53739E63C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1661872246627.png" alt="JohannesLindner_2-1661872246627.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have looked for a way to detect merges, but I haven't fond one, yet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You could just add this Attribute Rule:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Attribute Rule
// field: ParcelID
// triggers: Update

var id = $feature.ParcelID
if(id == null) {
    var new_id = NextSequenceValue("SequenceParcelID")
    return new_id
}
return id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And then delete the ParcelID in the Merge dialog:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_3-1661872377519.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49825i49976FB0C7161C0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_3-1661872377519.png" alt="JohannesLindner_3-1661872377519.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_4-1661872386738.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49826i87002DC2E4836CF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_4-1661872386738.png" alt="JohannesLindner_4-1661872386738.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, 30 Aug 2022 15:16:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1207721#M65435</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-08-30T15:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Attribute Rule $editContext.editType for Split and Merge Operation</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1208555#M65449</link>
      <description>&lt;P&gt;Thanks. I will check and update you&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 05:23:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-attribute-rule-editcontext-edittype-for/m-p/1208555#M65449</guid>
      <dc:creator>SU00861536</dc:creator>
      <dc:date>2022-09-01T05:23:12Z</dc:date>
    </item>
  </channel>
</rss>

