0

I am trying to add multiple fields to a list of feature classes in a geodatabase for NextGEN911. I am having trouble executing this line of code because I am getting the following error

#Import arcpy and allow overwrite
import arcpy
arcpy.env.overwriteOutput = True
#Set the environment settings
arcpy.env.workspace = "Z:\\\\ESInet\\PracticeESINet\\Practice.gdb"
#This returns a list of FeatureClasses in teh top of the level geodatabase
FcList = ["DaviePSAP", "DavieEMS", "DavieFire", "DaviePolice", "DavieSheriff"]
#Add all mandatory fields for all feature classes in .gdb using a loop
for fc in FcList:
 # The " " inputs mean just use defaults
 arcpy.AddField_management(fc, "sourceOFData", "TEXT", "", "", "75", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "Source of Last Edit Date", "DATE", "", "", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "uploadAuthority", "TEXT", "", "", "75", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "effectiveDate", "DATE", "","", "", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "expirationDate", "DATE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "county", "TEXT", "", "", "75", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "state", "TEXT", "", "", "2", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "country", "TEXT", "", "", "2", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "agencyID", "TEXT", "", "", "100", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "serviceURI", "TEXT", "", "", "254", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "serviceURN", "TEXT", "", "", "", "254", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "serviceNumber", "TEXT", "", "", "15", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "agencyVCardURI", "TEXT", "", "", "254", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "displayName", "TEXT", "", "", "60", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "comments", "TEXT", "", "", "100", "", "NULLABLE", "NON_REQUIRED", "")
 arcpy.AddField_management(fc, "gcLabel", "TEXT", "", "", "150", "", "NULLABLE", "NON_REQUIRED", "")
if fc in FcList == "DaviePSAP":
 arcpy.AddField_management(fc, "sourcePSAPUnqID", "TEXT", "", "", "254", "", "NULLABLE", "NON_REQUIRED", "")
FCList2 = [ "DavieEMS", "DavieFire", "DaviePolice", "DavieSheriff"]
for fc in FCList2:
 arcpy.AddField_management(fc, "sourceUnqID", "TEXT", "", "", "254", "", "NULLABLE", "NON_REQUIRED", "")
print "Add field is successful"`
Error:Traceback (most recent call last):
 File "C:/Users//Desktop/AddfieldsDiagnostic.py", line 19, in <module>
 arcpy.AddField_management(fc, "Source of Last Edit Date", "DATE", "", "", "", "True", "NON_REQUIRED", "")
 File "C:\Program Files (x86)\ArcGIS\Desktop10.6\ArcPy\arcpy\management.py", line 3435, in AddField
 raise e
ExecuteError: ERROR 000622: Failed to execute (Add Field). Parameters are not valid.
ERROR 000800: The value is not a member of NULLABLE | NON_NULLABLE.

I have previously referred back to a older post that solved this issue by replacing the Nullable strings with "True", but that did not work either. Any suggestions?

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Apr 29, 2020 at 19:47
2
  • I am also running into this error:TypeError: AddField() takes at most 10 arguments (11 given) Commented Apr 30, 2020 at 15:24
  • Is there a way to overcome this or should I simply create a new script using similar syntax for the other fields? Commented Apr 30, 2020 at 15:24

1 Answer 1

1

Include parameter names instead of empty strings to be sure you are providing the correct one:

arcpy.AddField_management(in_table=fc, field_name="sourceOFData", field_type="TEXT",field_length=75).

Note that Field length should be data type LONG not string (no quotes surrounding 75) see Add Field help.

This is incorrect syntax: if fc in FcList == "DaviePSAP":

Place the if within the for loop:

 ...
 arcpy.AddField_management(fc, "gcLabel", "TEXT", "", "", "150", "", "NULLABLE", "NON_REQUIRED", "")
 if fc == "DaviePSAP":
 #do something
answered Apr 30, 2020 at 5:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.