AnsweredAssumed Answered

Why would a python script run fine from within ArcMap but not as a geoprocessing service?

Question asked by paul.haakma on Oct 23, 2014
Latest reply on May 7, 2015 by paul.haakma

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)


whereClause = '"GlobalID" = ' + "'%s'" %JobGuid

with arcpy.da.UpdateCursor(Jobs, ["JobStatus"], whereClause) as JobCursor:

    for row in JobCursor:

        row[0] = 'X'





Any help here would be much appreciated.