<?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: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513644#M86311</link>
    <description>&lt;P&gt;As an update, we were able to add the previous X and Y values of the point in the event it was moved, displayed within the log table. Thanks again for the assistance from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/80456"&gt;@ZachBodenner&lt;/a&gt;&amp;nbsp;for getting us on the right track. Here below is our final arcade expression:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// User variables
var current_edit = "NONE";
var featureGeometry = null;
var prevX = null;
var prevY = null;

// User-editable fields
var fieldsArray = ['comments'];
var arrayLength = Count(fieldsArray);

// Process edit

// If a new feature was added
if ($editcontext.editType == 'INSERT') {
  current_edit = 'NEW FEATURE ';
  featureGeometry = $feature;
}

// If an existing feature was updated
if ($editcontext.editType == 'UPDATE') {
  current_edit = 'UPDATED FEATURE ';

  // if the geometries are not the same, record geometry update
  if ( !Equals( geometry($originalFeature), geometry($feature) )){
      current_edit = current_edit + " Geometry update";
      prevX = Geometry($originalFeature).x
      prevY = Geometry($originalFeature).y
      
  }

  // check for changes in attribute values, record original value if changed
  for (var i = 0; i &amp;lt; arrayLength; i++) {
    if ($originalFeature[fieldsArray[i]] != $feature[fieldsArray[i]]) {
      // geometryEditOnly = false;
      current_edit = current_edit + ' {' + fieldsArray[i] + ': ' + $originalFeature[fieldsArray[i]] + '}';
    }
  }
}

// If an existing feature was deleted
if ($editcontext.editType == 'DELETE') {
  current_edit = 'DELETED FEATURE ';
  featureGeometry = $feature; 

  for (var i = 0; i &amp;lt; arrayLength; i++) {
    current_edit = current_edit + '{' + fieldsArray[i] + ': ' + $feature[fieldsArray[i]] + '} ';
  }
}

// Write to the edit log table
return {
  edit: [{
      'className': 'DBO.AuditTracking',
      'adds': [{
          'attributes': {
            'edit_date': $feature.last_edited_date,
            'edit_feature': $feature.GlobalID,
            'editor': $feature.last_edited_user,
            'edit_action': $editcontext.editType,
            'edit_log': current_edit,
            'last_lat_Yvalue' : prevY,
            'last_long_Xvalue' : prevX
          },
          'shape' : featureGeometry      
        }
      ]
    }
  ]
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2024 14:52:38 GMT</pubDate>
    <dc:creator>Terry_Bearb</dc:creator>
    <dc:date>2024-08-01T14:52:38Z</dc:date>
    <item>
      <title>Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513089#M86261</link>
      <description>&lt;P&gt;I attended the Esri UC this year and this arcade expression was shown as an attribute rule in ArcGIS Pro that captures the audit history of a particular feature class / field(s), regarding the Insert, Update, and Delete event triggers. The script works great for capturing attribute changes, but as soon as you try to incorporate geometry changes, we see errors.&lt;/P&gt;&lt;P&gt;To only test the "Insert" event, I added the following lines:&lt;/P&gt;&lt;P&gt;var featureGeometry = null;&lt;/P&gt;&lt;P&gt;featureGeometry = $feature &lt;EM&gt;(within the insert event)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;'geometry' : featureGeometry &lt;EM&gt;(added to the returned dictionary)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Can anyone point out what can be wrong with this arcade expression being used in an attribute rule in ArcGIS Pro? At the moment when I try to create a new point feature, I receive an 'Invalid geometry' error&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// User variables
var current_edit = "NONE";
var featureGeometry = null; 

// User-editable fields
var fieldsArray = ['comments'];
var arrayLength = Count(fieldsArray);

// Process edit

// If a new feature was added
if ($editcontext.editType == 'INSERT') {
  current_edit = 'NEW FEATURE ';
  featureGeometry = $feature;
}

// If an existing feature was updated
if ($editcontext.editType == 'UPDATE') {
  current_edit = 'UPDATED FEATURE ';

  // if the geometries are not the same, record geometry update
  if ( !Equals( $originalFeature, $feature )){
      current_edit = current_edit + " Geometry update";
      
  }

  // check for changes in attribute values, record original value if changed
  for (var i = 0; i &amp;lt; arrayLength; i++) {
    if ($originalFeature[fieldsArray[i]] != $feature[fieldsArray[i]]) {
      // geometryEditOnly = false;
      current_edit = current_edit + ' {' + fieldsArray[i] + ': ' + $originalFeature[fieldsArray[i]] + '}';
    }
  }
}

// If an existing feature was deleted
if ($editcontext.editType == 'DELETE') {
  current_edit = 'DELETED FEATURE ';
  featureGeometry = $feature; 

  for (var i = 0; i &amp;lt; arrayLength; i++) {
    current_edit = current_edit + '{' + fieldsArray[i] + ': ' + $feature[fieldsArray[i]] + '} ';
  }
}

return {
  edit: [{
      'className': 'DBO.TestPointEdit',
      'adds': [{
          'attributes': {
            'edit_date': $feature.last_edited_date,
            'edit_feature': $feature.GlobalID,
            'editor': $feature.last_edited_user,
            'edit_action': $editcontext.editType,
            'edit_log': current_edit
          },
          'geometry' : featureGeometry      
        }
      ]
    }
  ]
};&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tbearb_0-1722449680460.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111217iBDF0224D466BA2A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tbearb_0-1722449680460.png" alt="tbearb_0-1722449680460.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 18:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513089#M86261</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-07-31T18:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513103#M86264</link>
      <description>&lt;P&gt;I got a slightly different error where it said 'Keyword 'geometry' cannot be used for a table'. I changed 'geometry' to 'Shape' and it worked.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 18:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513103#M86264</guid>
      <dc:creator>ZachBodenner</dc:creator>
      <dc:date>2024-07-31T18:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513123#M86265</link>
      <description>&lt;P&gt;Thanks, changing the word 'geometry' to 'shape' worked for me as well. Did you happen to have any luck with it recording the geometry when the original point was moved?&lt;/P&gt;&lt;P&gt;Incorporating&amp;nbsp;&lt;EM&gt;featureGeometry = $originalFeature&lt;/EM&gt; in the Update event if the geometry was changed.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 18:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513123#M86265</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-07-31T18:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513140#M86268</link>
      <description>&lt;P&gt;Maybe depends on what you mean by record? I did get the script to only record "Geometry Update" in the resulting log by changing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// if the geometries are not the same, record geometry update
  if ( !Equals( $originalFeature, $feature ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// if the geometries are not the same, record geometry update
  if ( !Equals( geometry($originalFeature), geometry($feature) ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That wont give you like the lat/long of the previous point or anything, but I imagine you might be able to add those fields to the log and then include them in the dictionary?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 19:24:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513140#M86268</guid>
      <dc:creator>ZachBodenner</dc:creator>
      <dc:date>2024-07-31T19:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513597#M86309</link>
      <description>&lt;P&gt;I appreciate that tip as well, that is working great for me. At the very least it helps better distinguish between what kind of edit happened - attribute vs geometry update. If we could update the dictionary and capture the previous lat/long that would be excellent.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 13:42:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513597#M86309</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-08-01T13:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513644#M86311</link>
      <description>&lt;P&gt;As an update, we were able to add the previous X and Y values of the point in the event it was moved, displayed within the log table. Thanks again for the assistance from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/80456"&gt;@ZachBodenner&lt;/a&gt;&amp;nbsp;for getting us on the right track. Here below is our final arcade expression:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;// User variables
var current_edit = "NONE";
var featureGeometry = null;
var prevX = null;
var prevY = null;

// User-editable fields
var fieldsArray = ['comments'];
var arrayLength = Count(fieldsArray);

// Process edit

// If a new feature was added
if ($editcontext.editType == 'INSERT') {
  current_edit = 'NEW FEATURE ';
  featureGeometry = $feature;
}

// If an existing feature was updated
if ($editcontext.editType == 'UPDATE') {
  current_edit = 'UPDATED FEATURE ';

  // if the geometries are not the same, record geometry update
  if ( !Equals( geometry($originalFeature), geometry($feature) )){
      current_edit = current_edit + " Geometry update";
      prevX = Geometry($originalFeature).x
      prevY = Geometry($originalFeature).y
      
  }

  // check for changes in attribute values, record original value if changed
  for (var i = 0; i &amp;lt; arrayLength; i++) {
    if ($originalFeature[fieldsArray[i]] != $feature[fieldsArray[i]]) {
      // geometryEditOnly = false;
      current_edit = current_edit + ' {' + fieldsArray[i] + ': ' + $originalFeature[fieldsArray[i]] + '}';
    }
  }
}

// If an existing feature was deleted
if ($editcontext.editType == 'DELETE') {
  current_edit = 'DELETED FEATURE ';
  featureGeometry = $feature; 

  for (var i = 0; i &amp;lt; arrayLength; i++) {
    current_edit = current_edit + '{' + fieldsArray[i] + ': ' + $feature[fieldsArray[i]] + '} ';
  }
}

// Write to the edit log table
return {
  edit: [{
      'className': 'DBO.AuditTracking',
      'adds': [{
          'attributes': {
            'edit_date': $feature.last_edited_date,
            'edit_feature': $feature.GlobalID,
            'editor': $feature.last_edited_user,
            'edit_action': $editcontext.editType,
            'edit_log': current_edit,
            'last_lat_Yvalue' : prevY,
            'last_long_Xvalue' : prevX
          },
          'shape' : featureGeometry      
        }
      ]
    }
  ]
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 14:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513644#M86311</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-08-01T14:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513691#M86313</link>
      <description>&lt;P&gt;Very welcome! Remember to mark it as a solution if you think it will help others who find the post!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 15:45:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1513691#M86313</guid>
      <dc:creator>ZachBodenner</dc:creator>
      <dc:date>2024-08-01T15:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1514912#M86443</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/80456"&gt;@ZachBodenner&lt;/a&gt;&amp;nbsp;We currently receive a "Value exceeds valid range of column" error on deletes. We occasionally notice the error come in on the update trigger while editing 12+ fields in Field Maps before hitting submit. Any idea what this could be?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tbearb_0-1722860871425.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111584iE93E0E731166BD5B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tbearb_0-1722860871425.png" alt="tbearb_0-1722860871425.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="tbearb_1-1722863165365.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111585iD41D2703E5FEFE7C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tbearb_1-1722863165365.png" alt="tbearb_1-1722863165365.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>Mon, 05 Aug 2024 13:06:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1514912#M86443</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-08-05T13:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1514914#M86444</link>
      <description>&lt;P&gt;Usually that's something to do with the length of the field (ie. your string field can contain 500 characters, but what you're attempting to write in has 501 or more characters).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 13:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1514914#M86444</guid>
      <dc:creator>ZachBodenner</dc:creator>
      <dc:date>2024-08-05T13:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1515184#M86469</link>
      <description>&lt;P&gt;That was exactly it, we just needed to increase the length of the text field.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 21:04:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1515184#M86469</guid>
      <dc:creator>Terry_Bearb</dc:creator>
      <dc:date>2024-08-05T21:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1515186#M86470</link>
      <description>&lt;P&gt;Love the easy ones!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 21:07:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1515186#M86470</guid>
      <dc:creator>ZachBodenner</dc:creator>
      <dc:date>2024-08-05T21:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Edit Log to capture Insert, Update, and Deletes via ArcGIS Arcade attribute rule</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1517648#M86709</link>
      <description>&lt;P&gt;Somewhat related:&amp;nbsp;&lt;BR /&gt;ArcGIS Pro Question: &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/track-changes-in-point-feature-class-with-records/m-p/1517605#M86700" target="_self"&gt;Track Changes in Point Feature Class with Records&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 18:41:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/edit-log-to-capture-insert-update-and-deletes-via/m-p/1517648#M86709</guid>
      <dc:creator>Bud</dc:creator>
      <dc:date>2024-08-09T18:41:06Z</dc:date>
    </item>
  </channel>
</rss>

