AnsweredAssumed Answered

Multivalue Field Parameter Usage

Question asked by connor.mcivor@fluor.com on Sep 3, 2019
Latest reply on Sep 3, 2019 by rvburton

I am using a multivalue field parameter which is supposed to be used in a "keepList" of fields. Script makes a copy of a user defined feature class and deletes all fields from the copy except for required fields and fields from the "keepList". I am not receiving any run errors however, the fields I specify in the parameter don't show in the output feature class. What I have so far:

 

# Appends fields detailed in the user input to keepList
Keep_Fields2 = Keep_Fields.split(";")
for item in Keep_Fields2:
     keepList.append(item)

# Deletes unnecesary fields from the Copy_KP      
fieldNames = [f.name for f in arcpy.Describe(Copy_KP).Fields if not (f.type in ["OID", "Geometry"] or f.name in ["Shape_Length", "Shape_Area"] or f.name.upper() in  keepList)] 
if fieldNames: 
    arcpy.DeleteField_management(Copy_KP, fieldNames)

 

Notes: "Copy_KP" is the copied feature class variable. "Keep_Fields" is the the multivalue field parameter variable. The "keepList" is an empty list '[ ]' (I know this empty list may be redundant, however I have been experimenting with various methods of accomplishing this task). I am going to make the variables more intuitive after I get this thing working.

Outcomes