Script tool validation - update Paramaters arguments?

05-07-2020 03:20 PM
Occasional Contributor III

creating some validation in a custom GP tool, getting an error in the tool after editing the validation code:

in TypeError: updateParameters() takes exactly 2 arguments (1 given) 

But, here's the code:

def updateParameters(self,parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
   if parameters[3].value:
      if parameters[3].value == "csv":
      parameters[4].enabled = False
      parameters[7].enabled = False
      parameters[8].enabled = False
      parameters[4].enabled = True
      parameters[7].enabled = True
      parameters[8].enabled = True
      parameters[9].enabled = False
      parameters[10].enabled = False


So, I see 2 arguments given, no?

2 Replies
MVP Legendary Contributor


where is the part of the script that calls it?

 def is a method for the object

9. Classes — Python 3.8.3rc1 documentation 

and it looks like you are passing a list to it, so I would expect

something.updateParameters(["a", "b", "csv", "d"])  # --- or something

where the parameter list has at least 11 entries

0 Kudos
Occasional Contributor III

Thanks Dan - 

I actually got it work simply by removing the 'parameters' from: 

def updateParameters(self, parameters):

So - 

def updateParameters(self):

got me rolling.  But it was all for naught, since validation code appears to be ignored when your script tool is published as a GP Service.