Select to view content in your preferred language

ArcGIS tool validation: How to add an error message to a parameter if a seperate multivalue parameter is empty

3640
0
10-30-2014 10:02 AM
MatthewHowe
New Contributor III

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. How do we use multivalue parameters in the validation script of a tool?

 

  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

0 Kudos
0 Replies