How to do Editor abort on AGOL REST endpoint

378
1
Jump to solution
12-05-2019 12:09 PM
DonMorrison1
Occasional Contributor III

I have a python program does does a series of updates on a group of feature classes that it accesses via an ArcGIS online REST endpoint that proxies the request to my ArcGIS server. I want to be able to back out the updates if something goes wrong but I can't get it to work. I reduced the code as shown below. The code sets an initial value , performs 3 updates (each with a new cursor, since in my real code I have to make multiple passes over the data), then aborts the edit session. If I run this against a file geodatabase it works as expected where at the end the records have the "original value". However if I run it against the ArcGIS Online REST endpoint it ends up with the 2nd update ('Edited -2') - as if only the data updated by the last cursor was backed off.

I'm running this with arcpy that got installed with ArcPro (currently at 2.4.2)  and Python 3.6.8 and Advanced license.

import arcpy

workspace = 'https://utility.arcgis.com/usrsvcs/servers/383d3cf85e8a41e9b7e8a5e9e8bb90b9/rest/services/ROW_testing/ERC/FeatureServer'
fc = workspace + '/0'

# Set initial values
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Original value'])

edit = arcpy.da.Editor(workspace)
edit.startEditing(True, False)
edit.startOperation()

with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 1'])
       
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 2'])
               
with arcpy.da.UpdateCursor(fc, ['LineName']) as cursor:
    for row in cursor:
        cursor.updateRow(['Edited - 3'])        
       
edit.abortOperation()
edit.stopEditing(False)

0 Kudos
1 Solution

Accepted Solutions
DonMorrison1
Occasional Contributor III

It turns out that Undo is not supported when editing a web layer - according to this help document.

There is a suggestion here to add that support

View solution in original post

0 Kudos
1 Reply
DonMorrison1
Occasional Contributor III

It turns out that Undo is not supported when editing a web layer - according to this help document.

There is a suggestion here to add that support

0 Kudos