I have a python script that opens an edit session on a feature layer and updates a field. It runs perfectly fine from within ArcMap, but after I publish it as a Geoprocessing Service and try to run in from a web app, it throws up an error saying "Objects in this class cannot be updated outside an edit session".
I understand the error, but the script DOES open an edit session.
The feature class has attachments enabled and is not versioned.
Attached is a screenshot of the error from the ArcGIS Server Manager from when I try to run the script from the webpage.
The python script is:
import arcpy
arcpy.env.workspace = "Database Connections\\GISMO.sde"
Jobs = "GISMO.DBO.Jobs"
JobGuid = '{55729082-574F-46FC-89DE-C9CCC2B4AD96}'
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, False)
edit.startOperation()
whereClause = '"GlobalID" = ' + "'%s'" %JobGuid
with arcpy.da.UpdateCursor(Jobs, ["JobStatus"], whereClause) as JobCursor:
for row in JobCursor:
row[0] = 'X'
JobCursor.updateRow(row)
edit.stopOperation()
edit.stopEditing(True)
Any help here would be much appreciated.
Thanks,
-Paul