Script tool validation - update Paramaters arguments?

613
2
05-07-2020 03:20 PM
AllenScully
Occasional Contributor II

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
   else:
      parameters[4].enabled = True
      parameters[7].enabled = True
      parameters[8].enabled = True
      parameters[9].enabled = False
      parameters[10].enabled = False

return

So, I see 2 arguments given, no?

0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

/blogs/dan_patterson/2016/08/14/script-formatting 

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
AllenScully
Occasional Contributor II

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.  

Allen

0 Kudos