0

I am somewhat new to Python, but I'm trying to create a custom python tool with 3 parameters, a workspace, a table and a Field from that table. I have the parameters set up like this:

def getParameterInfo(self):
    """Define parameter definitions"""
    parm0 = arcpy.Parameter(
    displayName = 'SSURGO geodatabase',
    name = 'geodatabase',
    datatype = "DEWorkspace",
    parameterType = "Required",
    direction = "Input")

    parm0.filter.list = ["Local Database"]

    parm1 = arcpy.Parameter(
    displayName = "Table",
    name = "Table",
    datatype = "DETable",
    parameterType = "Required",
    direction = "Input")

    parm2 = arcpy.Parameter(
    displayName = "Fields",
    name = "Fields",
    datatype = "Field",
    parameterType = "Required",
    direction = "Input",
    multiValue = True)

    parameters = [parm0, parm1, parm2]
    return parameters

I would like to create code in the updateParameters section that will allow the user to select a table and select a field from the fields within the table. Is there any way to do this?

  • 2
    In the tool interface properties you set the 'Obtained from' for the field to the table it will then offer a field in the chosen table. You shouldn't need to play with the validator to get this done. – Michael Stimson Mar 30 '17 at 23:01
  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. – Midavalo Mar 30 '17 at 23:04
1

You can use the parameterDependecies to achieve that. Simply add a line

    parm2 = arcpy.Parameter(
    displayName = "Fields",
    name = "Fields",
    datatype = "Field",
    parameterType = "Required",
    direction = "Input",
    multiValue = True)
    parm2.parameterDependencies = [parm1.name]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.