AnsweredAssumed Answered

Custom Pything script tool for ArcGIS using SDE

Question asked by rbasaria_DTS on Mar 27, 2018
Latest reply on Mar 28, 2018 by rastrauch

Hello. I am building an ArcGIS Toolbox tool that needs to join data from an SDE view table to an ArcGIS File Geodatabase feature class.


Currently, I am receiving this error message: 


Traceback (most recent call last):
File "C:\Projects\MDC\", line 53, in <module>
arcpy.CalculateField_management(gdfc, gdfc+"."+gai, vwfc+"."+vai, "VB", "")
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\", line 3360, in CalculateField
raise e
ExecuteError: ERROR 999999: Error executing function.
Object required: 'MDCTest_1025'
Failed to execute (CalculateField).

Failed to execute (MDCSingleFC).


The code that I have so far is below.


Eventually, I will need to convert this to a script that will automatically run against 115 different feature classes on a weekly schedule, running against fixed database, with error logging being saved to a specific location...but one problem at a time.


Also, I know that some of these feature classes will not have all of the fields listed as variable in this script. Is there a way to tell the script to skip any fields that it does not find?


import arcpy, sys, string, os, subprocess

gdfc = arcpy.GetParameterAsText(0)
vwfc = arcpy.GetParameterAsText(1)

vwd = r'C:\Users\rbasaria\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\MDCTest_1025.sde'

gca = vca = "Conservation_Area_Name"
gcn = vcn = "Conservation_Area_Number"
gn = vn = "Network"

gfi = "Field_ID"
gai = "Asset_ID"
gt1n = "Tier_1_System_Name"
gt1t = "Tier_1_System_Type"
gt2n = "Tier_2_Major_Subsystem_Name"
gt2t = "Tier_2_Major_Subsystem_Type"
gt3n = "Tier_3_Minor_Subsystem_Name"
gt3t = "Tier_3_Minor_Subsystem_Type"
gt4n = "Asset_Name"

vfi = "FieldID"
vai = "AssetID"
vt1n = "Tier_1_Name"
vt1t = "Tier_1_Type"
vt2n = "Tier_2_Name"
vt2t = "Tier_2_Type"
vt3n = "Tier_3_Name"
vt3t = "Tier_3_Type"
vt4n = "Tier_4_Name"

slct = gdfc+"."+gai+" IS NULL OR ("+gdfc+"."+gai+" <> "+vwfc+"."+vai+")"

arcpy.AddJoin_management(gdfc, gfi, vwfc, vfi)
arcpy.SelectLayerByAttribute_management(gdfc, "NEW_SELECTION", slct)
arcpy.CalculateField_management(gdfc, gdfc+"."+gai, vwfc+"."+vai, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gca, vwfc+"."+vca, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gcn, vwfc+"."+vcn, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gn, vwfc+"."+vn, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt1n, vwfc+"."+vt1n, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt1t, vwfc+"."+vt1t, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt2n, vwfc+"."+vt2n, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt2t, vwfc+"."+vt2t, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt3n, vwfc+"."+vt3n, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt3t, vwfc+"."+vt3t, "VB", "")
arcpy.CalculateField_management(gdfc, gdfc+"."+gt4n, vwfc+"."+vt4n, "VB", "")
arcpy.SelectLayerByAttribute(gdfc, "CLEAR_SELECTION", "")