I keep getting this error in my python script "ExecuteError: Failed to execute. Parameters are not valid.ERROR 000728: Field COSTCENTREREL_ID does not exist within tableFailed to execute (CalculateField)." when i check the input file, it does have the fie

1961
4
12-23-2016 06:56 AM
AbuzarPopal
New Contributor
0 Kudos
4 Replies
JoshuaBixby
MVP Esteemed Contributor

The GeoNet Help space is for help with GeoNet itself, not for general help from GeoNet users.  I am sharing this with https://community.esri.com/community/developers/gis-developers/python?sr=search&searchId=f7391898-3f...‌ and https://community.esri.com/community/gis?sr=search&searchId=5fac74d6-fe0d-44df-ae1e-04a3cc2b532e&sea...‌.

Are you using ArcMap or ArcGIS Pro?  What version?  What is the backend data store for the table, shapefile, file geodatabase, enterprise geodatabase?  It looks like you are using Model Builder, can you share either the whole model or a subset of it?

0 Kudos
AbuzarPopal
New Contributor

I exported the code from modelbuilder but it gives me the error above. Below is the python code.


# Import arcpy module2
import arcpy

# Local variables:
Outlets = "D:\\Apps\\Retail\\LA_Working\\ABUZAR_WORKING\\PORTAL\\LA_Daily.gdb\\Outlets"
Outlets_PointDistance = "D:\\Apps\\Retail\\LA_Working\\ABUZAR_WORKING\\MYTESTS\\MyScratchWorkSpace\\MyScratch.gdb\\Outlets_PointDistance"
Outlets_PointDistance__6_ = Outlets_PointDistance
Outlets_PointDistance__5_ = Outlets_PointDistance__6_
Outlets__3_ = "D:\\Apps\\Retail\\LA_Working\\ABUZAR_WORKING\\PORTAL\\LA_Daily.gdb\\Outlets"
Outlets_PointDistance__3_ = Outlets__3_
Outlets_PointDistance__2_ = Outlets_PointDistance__3_
Outlets_PointDistance_10km_ODMatrix = "D:\\Apps\\Retail\\LA_Working\\ABUZAR_WORKING\\MYTESTS\\MyScratchWorkSpace\\MyScratch.gdb\\Outlets_PointDistance_10km_ODMatrix"
Delete_succeeded = "true"

# Process: Point Distance
arcpy.PointDistance_analysis(Outlets, Outlets, Outlets_PointDistance, "10 Kilometers")

# Process: Add Field
arcpy.AddField_management(Outlets_PointDistance, "COSTCENTREREL_ID", "TEXT", "", "", "12", "", "NULLABLE", "NON_REQUIRED", "")

# Process: Join INPUT Cost Centre
tempEnvironment0 = arcpy.env.newPrecision
arcpy.env.newPrecision = "SINGLE"
tempEnvironment1 = arcpy.env.autoCommit
arcpy.env.autoCommit = "1000"
tempEnvironment2 = arcpy.env.XYResolution
arcpy.env.XYResolution = ""
tempEnvironment3 = arcpy.env.XYDomain
arcpy.env.XYDomain = ""
tempEnvironment4 = arcpy.env.scratchWorkspace
arcpy.env.scratchWorkspace = "D:\\Apps\\Retail\\TOOLS\\CALLFOR_WEEKLY\\ScratchWorkSpace\\Scratch.gdb"
tempEnvironment5 = arcpy.env.cartographicPartitions
arcpy.env.cartographicPartitions = ""
tempEnvironment6 = arcpy.env.terrainMemoryUsage
arcpy.env.terrainMemoryUsage = "false"
tempEnvironment7 = arcpy.env.MTolerance
arcpy.env.MTolerance = ""
tempEnvironment8 = arcpy.env.compression
arcpy.env.compression = "LZ77"
tempEnvironment9 = arcpy.env.coincidentPoints
arcpy.env.coincidentPoints = "MEAN"
tempEnvironment10 = arcpy.env.randomGenerator
arcpy.env.randomGenerator = "0 ACM599"
tempEnvironment11 = arcpy.env.outputCoordinateSystem
arcpy.env.outputCoordinateSystem = ""
tempEnvironment12 = arcpy.env.rasterStatistics
arcpy.env.rasterStatistics = "STATISTICS 1 1"
tempEnvironment13 = arcpy.env.ZDomain
arcpy.env.ZDomain = ""
tempEnvironment14 = arcpy.env.transferDomains
arcpy.env.transferDomains = "false"
tempEnvironment15 = arcpy.env.resamplingMethod
arcpy.env.resamplingMethod = "NEAREST"
tempEnvironment16 = arcpy.env.snapRaster
arcpy.env.snapRaster = ""
tempEnvironment17 = arcpy.env.projectCompare
arcpy.env.projectCompare = "NONE"
tempEnvironment18 = arcpy.env.cartographicCoordinateSystem
arcpy.env.cartographicCoordinateSystem = ""
tempEnvironment19 = arcpy.env.configKeyword
arcpy.env.configKeyword = ""
tempEnvironment20 = arcpy.env.outputZFlag
arcpy.env.outputZFlag = "Same As Input"
tempEnvironment21 = arcpy.env.qualifiedFieldNames
arcpy.env.qualifiedFieldNames = "true"
tempEnvironment22 = arcpy.env.tileSize
arcpy.env.tileSize = "128 128"
tempEnvironment23 = arcpy.env.parallelProcessingFactor
arcpy.env.parallelProcessingFactor = ""
tempEnvironment24 = arcpy.env.pyramid
arcpy.env.pyramid = "PYRAMIDS -1 NEAREST DEFAULT 75 NO_SKIP"
tempEnvironment25 = arcpy.env.referenceScale
arcpy.env.referenceScale = ""
tempEnvironment26 = arcpy.env.extent
arcpy.env.extent = "DEFAULT"
tempEnvironment27 = arcpy.env.XYTolerance
arcpy.env.XYTolerance = ""
tempEnvironment28 = arcpy.env.tinSaveVersion
arcpy.env.tinSaveVersion = "CURRENT"
tempEnvironment29 = arcpy.env.nodata
arcpy.env.nodata = "NONE"
tempEnvironment30 = arcpy.env.MDomain
arcpy.env.MDomain = ""
tempEnvironment31 = arcpy.env.spatialGrid1
arcpy.env.spatialGrid1 = "0"
tempEnvironment32 = arcpy.env.cellSize
arcpy.env.cellSize = "MAXOF"
tempEnvironment33 = arcpy.env.outputZValue
arcpy.env.outputZValue = ""
tempEnvironment34 = arcpy.env.outputMFlag
arcpy.env.outputMFlag = "Same As Input"
tempEnvironment35 = arcpy.env.geographicTransformations
arcpy.env.geographicTransformations = "NAD_1927_To_NAD_1983_NADCON"
tempEnvironment36 = arcpy.env.spatialGrid2
arcpy.env.spatialGrid2 = "0"
tempEnvironment37 = arcpy.env.ZResolution
arcpy.env.ZResolution = ""
tempEnvironment38 = arcpy.env.mask
arcpy.env.mask = ""
tempEnvironment39 = arcpy.env.spatialGrid3
arcpy.env.spatialGrid3 = "0"
tempEnvironment40 = arcpy.env.maintainSpatialIndex
arcpy.env.maintainSpatialIndex = "false"
tempEnvironment41 = arcpy.env.workspace
arcpy.env.workspace = "D:\\Apps\\Retail\\TOOLS\\CALLFOR_WEEKLY\\ToolData\\CallForWeekly.gdb"
tempEnvironment42 = arcpy.env.MResolution
arcpy.env.MResolution = ""
tempEnvironment43 = arcpy.env.derivedPrecision
arcpy.env.derivedPrecision = "HIGHEST"
tempEnvironment44 = arcpy.env.ZTolerance
arcpy.env.ZTolerance = ""
arcpy.JoinField_management(Outlets_PointDistance__6_, "INPUT_FID", Outlets__3_, "OBJECTID", "Rcnumber")
arcpy.env.newPrecision = tempEnvironment0
arcpy.env.autoCommit = tempEnvironment1
arcpy.env.XYResolution = tempEnvironment2
arcpy.env.XYDomain = tempEnvironment3
arcpy.env.scratchWorkspace = tempEnvironment4
arcpy.env.cartographicPartitions = tempEnvironment5
arcpy.env.terrainMemoryUsage = tempEnvironment6
arcpy.env.MTolerance = tempEnvironment7
arcpy.env.compression = tempEnvironment8
arcpy.env.coincidentPoints = tempEnvironment9
arcpy.env.randomGenerator = tempEnvironment10
arcpy.env.outputCoordinateSystem = tempEnvironment11
arcpy.env.rasterStatistics = tempEnvironment12
arcpy.env.ZDomain = tempEnvironment13
arcpy.env.transferDomains = tempEnvironment14
arcpy.env.resamplingMethod = tempEnvironment15
arcpy.env.snapRaster = tempEnvironment16
arcpy.env.projectCompare = tempEnvironment17
arcpy.env.cartographicCoordinateSystem = tempEnvironment18
arcpy.env.configKeyword = tempEnvironment19
arcpy.env.outputZFlag = tempEnvironment20
arcpy.env.qualifiedFieldNames = tempEnvironment21
arcpy.env.tileSize = tempEnvironment22
arcpy.env.parallelProcessingFactor = tempEnvironment23
arcpy.env.pyramid = tempEnvironment24
arcpy.env.referenceScale = tempEnvironment25
arcpy.env.extent = tempEnvironment26
arcpy.env.XYTolerance = tempEnvironment27
arcpy.env.tinSaveVersion = tempEnvironment28
arcpy.env.nodata = tempEnvironment29
arcpy.env.MDomain = tempEnvironment30
arcpy.env.spatialGrid1 = tempEnvironment31
arcpy.env.cellSize = tempEnvironment32
arcpy.env.outputZValue = tempEnvironment33
arcpy.env.outputMFlag = tempEnvironment34
arcpy.env.geographicTransformations = tempEnvironment35
arcpy.env.spatialGrid2 = tempEnvironment36
arcpy.env.ZResolution = tempEnvironment37
arcpy.env.mask = tempEnvironment38
arcpy.env.spatialGrid3 = tempEnvironment39
arcpy.env.maintainSpatialIndex = tempEnvironment40
arcpy.env.workspace = tempEnvironment41
arcpy.env.MResolution = tempEnvironment42
arcpy.env.derivedPrecision = tempEnvironment43
arcpy.env.ZTolerance = tempEnvironment44

# Process: Join Field
arcpy.JoinField_management(Outlets_PointDistance__5_, "NEAR_FID", Outlets__3_, "OBJECTID", "Rcnumber")

# Process: Calculate Field
arcpy.CalculateField_management(Outlets_PointDistance__5_, "COSTCENTREREL_ID", "!Rcnumber!+ !Rcnumber_1!", "PYTHON_9.3", "")

# Process: Copy Rows
arcpy.CopyRows_management(Outlets_PointDistance__2_, Outlets_PointDistance_10km_ODMatrix, "")

# Process: Delete
arcpy.Delete_management(Outlets_PointDistance, "")

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You are running arcpy.JoinField_management right before arcpy.CalculateField_management.  Depending on the backend data stores and fields in the tables, there can be situations where the fully qualified name is required, e.g., table_name.field_name instead of just field_name.

As an experiment, what if you don't do the join and see if you can calculate the field to some arbitrary number.  Does that work?

BlakeTerhune
MVP Regular Contributor