1

I'm simply trying to disable parameter 1 if parameter 0 if entered. I modified the following, but it does not work, do I need to return anything?

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[0].value == False:
      self.params[1].enabled = False
  else:
      self.params[1].enabled = True

  return [self.params[0],self.params[1]]

1 Answer 1

5

You're doing the opposite, right? Disabling parameter 1 if parameter 0 is empty. You don't need to return anything. I would just write this (if parameters are enabled by default):

def updateParameters(self, params):

    if params[0].value:
        params[1].enabled = 0

    return

or:

def updateParameters(self):

    if self.params[0].value:
        self.params[1].enabled = 0

    return
11
  • I see you added params argument, do I need to change anything else in the validation script? Apr 1, 2014 at 11:58
  • No, this will work as well: def updateParameters(self): if self.params[0].value: self.params[1].enabled = 0 return
    – GISGe
    Apr 1, 2014 at 12:02
  • Sorry no code formatting available in comments
    – GISGe
    Apr 1, 2014 at 12:02
  • Thank you, that worked. Very simple. Do you know if it's possible if a user selects a GDB as param1 that the user can then select 1 unique field from each feature class contained in that GDB? Apr 1, 2014 at 12:05
  • 1
    @GISGe Why not edit it into your Answer where you can format it?
    – PolyGeo
    Apr 1, 2014 at 12:06

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.