3

I have three tool parameters;

  1. an input point feature class,
  2. a (multivalue) list of fields derived from the input feature class and
  3. an output file location to export to Excel.

I have filtered the fields derived from the feature so only Short, Long, Float, Double, Text and Date types are accepted. I would like to set the tool validation so that if a point feature class is selected that doesn't contain any fields of said types, an error message will show by the input point feature class parameter. The below code shows where I am at currently however does not present an error message.

  def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter.  This method is called after internal validation."""

if self.params[0].altered and str(self.params[0].value) != "":
  if not self.params[1].value:
    self.params[0].setErrorMessage("The selected feature class does not have any fields. Please check and try again.")
  else:
    self.params[0].clearMessage()
return

closed as unclear what you're asking by PolyGeo Jul 20 '16 at 5:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I've done some fiddling around with tool validation and your example, the clue might lay in that self.params[1].value is not an empty string, just an empty value, so comparing it with "" will yield False. Another thing is that I never got the error messages printed to the dialog using the updateParameters function. Using the updateMessages function it worked, but now they never cleared. – Menno Oct 30 '14 at 14:55
  • Thanks Menno. I´ve still not found a solution as I don´t know how the multivalue list works in the validation script. I´ll keep trying and post a solution if I come across one. – Howeitzer Nov 1 '14 at 9:04
  • To help on this one I think we need you to provide all the code for a simple test tool that illustrates what you are trying to do and where you are stuck. – PolyGeo Jul 20 '16 at 5:49