I'm trying to derive a Python Toolbox parameter from another parameter. I'd like to have a tool which determines fields from an input table and applies the list as a filter to a second parameter. This is what I've come up with so far:
class Tool(object):
def __init__(self):
self.label = "MFF"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
#input excel spreadsheet table
lkTab = arcpy.Parameter (
displayName = "Leak Excel Worksheet",
name = "intab",
datatype = "DETable",
parameterType = "Required",
direction = "Input")
#input table field
lkLkTab = arcpy.Parameter (
displayName = "Leak Excel Worksheet Leak Field",
name = "lkLkFld",
datatype = "Field",
parameterType = "Required",
direction = "Input")
return [lkTab, lkLkTab]
def updateParameters(self, parameters):
flds = []
tab = parameters [0].valueAsText
if tab:
flds = [f.name for f in arcpy.ListFields (tab)]
if not parameters [1].valueAsText in flds:
parameters [1].value = None
#trying here to apply filter list of fields
parameters [1].filter.list = flds
My field list parameter doesn't get populated however when I indicate a table in the first parameter:
How do filter a parameter with a list of fields from another parameter?