Add Functionality to Delete a Field (if it exists)

Idea created by dburton3 on Jan 4, 2019
    • dburton3

    Currently with ArcPro the delete field tool in data management will generate a warning if a field doesn't exist in the input and error out the task. Now this might be a bug, as I don't think warnings are supposed to stop an iterating script dead in its tracks, but what if you made the code like so:

    inFC = arcpy.GetParameterAsText(0)

    ListOfInputFields = arcpy.GetParameterAsText(1)

    ListOfInputFields = ListOfInputFields.split(";")

    for delField in ListOfInputFields: 

        fldLst = arcpy.ListFields(inFC) 

        fldLst2 = []

        for fld in fldLst:


        if delField is in fldLst:



            arcpy.AddMessage(deleteField + " was not found in " + inputFC)


    Anyways just an idea. It's probably not the best way of writing out the code but maybe you get the point?