ionarawilson

Field OID does not exist within table - PLEASE HELP!

Discussion created by ionarawilson on Oct 10, 2013
Latest reply on Oct 11, 2013 by ionarawilson
If I run the geoprocessing service to the point before the Identity Analysis, it works fine, but if I add the Identity Analysis, the server gives me an error saying the OID field does not exist. Please help! I have no idea why it is doing this. The script tool has two parameters as feature sets that represent the data that is referenced by the variable Input_polygons and Counties.

Note: there are no errors if I run the script in ArcMap and the OID field was created today, many weeks after I created the database (in SDE)

Here is the error

  line 60, in arcpy.CalculateField_management(Input_Polygons, g_ESRI_variable_2, g_ESRI_variable_3, "PYTHON") File "c:\program files\arcgis\server\arcpy\arcpy\management.py", line 3129, in CalculateField raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000728: Field OID does not exist within table Failed to execute (CalculateField). Failed to execute (CalcFeaturesStewardship3). Failed to execute (CalcFeaturesStewardshipOneParameter).

Here is the script

# Import arcpy module
import os, sys, arcpy, traceback, arcgisscripting
#arcpy.env.workspace = "Database Connections\\sars.sde\\"


# Script arguments

#Selecting_Features = arcpy.GetParameterAsText(0)

Input_Polygons = "Stewardship"
Counties = "Counties"
#Final_Output = value
arcpy.env.scratchWorkspace = "d:\\ArcGISData\\SARS\\Python_10April2013\\SARS.gdb"


# create output feature for spatial join
outstewardshipcounties = os.path.join(arcpy.env.scratchGDB, "StewardshipCounties")


with arcpy.da.UpdateCursor(Input_Polygons, ("DateStart", "PlanID", "FFY")) as rows:


      
    for row in rows:

        if not (row[1] or "").strip(): #covers blank, one blank space, or Null

           Datestarstr1 = row[0]

           Datestarstr2 = str(Datestarstr1)
      


           yearonly = Datestarstr2[0:4]

                
           row[2] = yearonly


           rows.updateRow(row)  


#run spatial join tool
arcpy.CalculateField_management(Input_Polygons, "OID", '!OBJECTID!', "PYTHON")

arcpy.Identity_analysis(Input_Polygons, Counties, outstewardshipcounties)

Outcomes