Error in adding table to field mappings

Discussion created by ionarawilson on Oct 10, 2013
Latest reply on Oct 11, 2013 by ionarawilson
This code works fine when I run in Arcmap but when I run the geoprocessing service I get the error:

"error in adding table to field mappings"
Does anybody know why this is happening?

arcpy.env.scratchWorkspace = "d:\\ArcGISData\\SARS\\Python_10April2013\\SARS.gdb"

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


# Create new field mappings and add both feature classes

fieldmappings = arcpy.FieldMappings()

# create output feature for spatial join
outstewardshipcounties = os.path.join(arcpy.env.scratchGDB, "StewardshipCounties")
arcpy.CalculateField_management(Input_Polygons, "OID", '!OBJECTID!', "PYTHON")
arcpy.CalculateField_management(Counties, "OID", '!OBJECTID!', "PYTHON")
#run spatial joint tool

arcpy.SpatialJoin_analysis(Input_Polygons, Counties, outstewardshipcounties , "#", "#", fieldmappings, "HAVE_THEIR_CENTER_IN")

#create dictionary

path_dict = { }
rows = arcpy.SearchCursor(outstewardshipcounties)
for row in rows:
    keyrow =  row.OID
    valrow = row.FIPS_TXT
    path_dict[keyrow] = valrow

urows = arcpy.UpdateCursor(Input_Polygons)
for urow in urows:

    upkey = urow.OID
    if upkey in path_dict:
        urow.setValue("County", path_dict[upkey])
del row, rows, urow, urows