Figured it out. You need to define the filter types of the field variables as "ValueList" instead of "FieldList" so that they can be used as string lists. The code creates a function that returns field values as a list for a feature class parameter. Param 2 is one fc option, Params 3,5,7 are the other option (user can choose either Param 2 or Params 3,5,7). Params 4,6,8 are field lists either pulled from Param 2 or Params 3,5,7.class ToolValidator:
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
def __init__(self):
"""Setup arcpy and the list of tool parameters."""
import arcpy
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
self.params[4].filter.type = "ValueList"
self.params[6].filter.type = "ValueList"
self.params[8].filter.type = "ValueList"
return
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
# Define function that returns field values for a fc parameter (par) to the field parameter (field);
# i.e. changeFilter(2,4) takes the fields from (2) and returns them as a list to (4)
def changeFilter(par,field):
if self.params[par].value:
list = []
fc = arcpy.Describe(self.params[par].value)
for x in fc.fields:
list.append(x.name)
self.params[field].filter.list = list
#if self.params[1].altered = True:
if self.params[1].value == "Use Existing Intersect":
self.params[4].filter.list = []
self.params[6].filter.list = []
self.params[8].filter.list = []
changeFilter(2,4)
changeFilter(2,6)
changeFilter(2,8)
self.params[2].enabled = True
self.params[3].enabled = False
self.params[5].enabled = False
self.params[7].enabled = False
elif self.params[1].value == "Build New Intersect":
self.params[4].filter.list = []
self.params[6].filter.list = []
self.params[8].filter.list = []
changeFilter(3,4)
changeFilter(5,6)
changeFilter(7,8)
self.params[2].enabled = False
self.params[3].enabled = True
self.params[5].enabled = True
self.params[7].enabled = True
else:
self.params[2].enabled = False
self.params[3].enabled = False
self.params[5].enabled = False
self.params[7].enabled = False
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return