Update Paramter not working?

11-24-2013 04:33 PM
Occasional Contributor III
I have a script tool that takes four inputs.

1. a feature class
2. a field - obtained from feature class
3. an address - string - A drop down from this parameter is based on information in the selected field above.
4. output file

I've updated the validation code so that the values in the selected field (#2) become the choise list for #3. I've used this script several times before with no problem, but now it doesn't perform correctly.Am I over looking something?

Validation Code:

import arcpy
class ToolValidator(object):
  """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."""
    self.params = arcpy.GetParameterInfo()

  def initializeParameters(self):
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parmater
    has been changed."""
    if self.params[1].altered:
      fc = str(self.params[0].value)
      fieldname = str(self.params[1].value)
      sc = arcpy.SearchCursor(fc)
      valueList = []
      for row in sc:
      self.params[3].filter.list = valueList

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""

Screenshot of parameters:

0 Kudos
1 Reply
Occasional Contributor III
Your index is off.  It should be
self.params[2].filter.list = valueList

not 3.

Also, for future reference, here's a blog about populating a parameter with field values. 

Generating a choice list from a field
0 Kudos