Hi All!
I have been struggling with this one for a few days now, and can't figure out what is going wrong. I am automating an append function that I now do manually (using a selection from a feature service in ArcPro and then appending to SDE) with python instead.
The goal is to use the OIDs for the recent features to query the feature service, and then append the resulting feature set to an SDE feature class. The query works perfectly, and I get a feature set, I have then converted the ArcGIS API for Python version of the feature set to the arcpy version so that I can append the records.
Once I get to the append I receive the error code 160250: Objects in this class cannot be updated outside an edit session Failed to execute (Append). Even when working in an editing session.
Here is the bare bones of what I am doing:
# Get the Feature set using Python API query
# Oids are gathered as a list
imputStringOids = []
#Connect to ArcGIS online and get the feature service
gis = GIS('home')
fs = gis.content.get('XXXXXXXXXXXXXXXXXXx')
add_Vssl = fs.layers[0]
# Query the feature service using the oids once they have been converted to a string
oids = "OBJECTID in (" + str(imputStringOids)[1:-1] + ")"
vsslDetailsQuery = add_Vssl.query(where=oids)
# Checks to see what format the result is in, its always <FeatureSet> X number of features
vsslDetailsQuery
# Convert the API feature Set to a arcpy Feature set ( this is one step I am not very confident in).
feature_set_arcpy = arcpy.FeatureSet(vsslDetailsQuery)
#Begin editing session and append
workspace = os.path.dirname("X:\xyz\xyzx\xyzxy")
edit = arcpy.da.Editor(workspace)
edit.startEditing(with_undo=True, multiuser_mode=True)
edit.startOperation()
arcpy.management.Append(inputs=feature_set_arcpy,
target=dvrp_Feature_Class, schema_type="NO_TEST", field_mapping= CRAZY LONG FIELD MAPPING, subtype="", expression="", match_fields=None, update_geometry="NOT_UPDATE_GEOMETRY")
edit.stopOperation()
edit.stopEditing(True)
Other possibly useful info:
- The Oids are being collected from emails that come in when a new record is recorded
- The append is going into a traditionally versioned SDE feature class within an Oracle database
- I am open to changing this whole method up if there is a better way to do it, my other idea was to match my current workflow by using a map object to do the selection of the oids and then the append, but the feature set seems like it should be an easier method.
Thank you for any help you can give me!!!
Andrew