AnsweredAssumed Answered

Getting ObjectID's using Fieldmapping in FeatureClasstoFeatureClass tool

Question asked by MCusumano on Jun 6, 2013
Latest reply on Jun 6, 2013 by MCusumano
I have field mapping working for all fields but when I try to pull the ObjectID's in I get an error message:

"FieldMappings: Error in getting field map from field mapping for GetFieldMap"

Here is my code:

CONVERSION_InputPrefix = "Database Connections\\Sun120 - 5151.sde\\" CONVERSION_CPTestPoint = CONVERSION_InputPrefix + "CONVERSION.GasDataset\\CONVERSION.CPTestPoint"   try:     fieldmappings = arcpy.FieldMappings()     fieldmappings.addTable(CONVERSION_CPTestPoint)         fieldmap_CPTESTPOINT = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("OBJECTID"))     fieldmap_CPTESTPOINT.addInputField(CONVERSION_CPTestPoint, "OBJECTID")      fieldmap_CPTESTPOINT = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("GAS_CORR_TEST_STA_NO"))     fieldmap_CPTESTPOINT.addInputField(CONVERSION_CPTestPoint, "GAS_CORR_TEST_STA_NO")     fieldmap_CPTESTPOINT = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("STATE_MCD"))     fieldmap_CPTESTPOINT.addInputField(CONVERSION_CPTestPoint, "STATE_MCD")     fieldmap_CPTESTPOINT = fieldmappings.getFieldMap(fieldmappings.findFieldMapIndex("DISTRICT_NAME"))     fieldmap_CPTESTPOINT.addInputField(CONVERSION_CPTestPoint, "DISTRICT_NAME")      fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ANCILLARYROLE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ENABLED"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CREATIONUSER"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("DATECREATED"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("DATEMODIFIED"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("LASTUSER"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("LEGACYID"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("INSTALLATIONDATE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("COMMENTS"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("LOCATIONDESCRIPTION"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("OPERATINGSTATUS"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("PROPERTYUNITCODE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("SUBTYPECD"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("SYMBOLROTATION"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("GASTRACEWEIGHT"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ISR_NO"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ISR_SEQ_NO"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ISR_EXTERNAL_NO1"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("SAP_EQUIPMENT_NO"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("SAP_FUNCTIONAL_LOCATION"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("TESTPOINTTYPE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("WIRECOUNT"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("APPT_NO"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("STREET_NAME1"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("STREET_NAME2"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("ZIP_CODE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("DELETE_INDICATOR"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CATHODICPROTECTIONDEVICE"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CIVIC_NO"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CPSYSTEMOBJECTID"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("CONVERSIONID"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("STR_SEQ_ID"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("IMAGEID"))     fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("IMAGELINK"))      except Exception as e:     print e     logging.error(": Error setting up field mappings: %s" %(str(e)))     msgTxtErr = msgTxtErr + "\n" + "* Error setting up field mappings: " + str(e)     flMail(from_addr, to_addr, msgTxtErr)


Again if I comment out the ObjectID portion the code runs fine and I get the fields I want in the output. What do I have to do to get the existing ObjectID

Outcomes