Dynamic Update of Value list Filter

849
2
03-13-2020 07:37 AM
AyokunleAdebisi1
New Contributor III

Hello, 

Please I am working to dynamically update a value list  where by If the user enters : "Taucher" in the second parameter, the third parameter  will dynamically contain the list that belong to what is selected in the second Parameter. If "Kormoran" is selected in the second parameter, the third parameter  will dynamically contain the following list that belong to what is selected in the second Parameter. My validation code looks like this but it does not seems to have any effect: Please I need help to solve the issue. Thanks

0 Kudos
2 Replies
RandyBurton
MVP Alum

I haven't fully tested it, but you might try this for the tool validator:

import arcpy
class ToolValidator(object):

  def __init__(self):
     self.params = arcpy.GetParameterInfo()

  def initializeParameters(self):
    self.params[0].filter.list = ["Taucher", "Ganse", "Kormoran"]
    self.params[0].value = self.params[0].filter.list[0] # default: Taucher
    self.params[1].filter.list = ["Haubentaucher", "Zwergtaucher", "Prachttaucher"]
    self.params[1].value = self.params[1].filter.list[0] # default: Haubentaucher
    return

  def updateParameters(self):
    if self.params[0].value not in self.params[0].filter.list: # set defaults
      self.params[0].value = self.params[0].filter.list[0] # default: Taucher
      self.params[1].filter.list = ["Haubentaucher", "Zwergtaucher", "Prachttaucher"]
      self.params[1].value = self.params[1].filter.list[0] # default: Haubentaucher

    elif self.params[0].value ==  "Taucher": # Taucher selected
      self.params[1].filter.list = ["Haubentaucher", "Zwergtaucher", "Prachttaucher"] # update list
      if self.params[1].value not in self.params[1].filter.list: # if selection not in list
        self.params[1].value = self.params[1].filter.list[0] # first option becomes default

    elif self.params[0].value ==  "Ganse": # Ganse selected
      self.params[1].filter.list = ["Brandente", "Nonnegans","Saatgans"]
      if self.params[1].value not in self.params[1].filter.list:
        self.params[1].value = self.params[1].filter.list[0]
      
    elif self.params[0].value ==  "Kormoran": # Kormoran selected
      self.params[1].filter.list = ["Kormoran"]
      if self.params[1].value not in self.params[1].filter.list:
        self.params[1].value = self.params[1].filter.list[0]

    return

  def updateMessages(self):
    return
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope it helps.

AyokunleAdebisi1
New Contributor III

It works perfectly in arcgis desktop but thee filtering does not work when exported to arcgis online to use .