I'm trying to use the ToolValidator function to update the content of the drop down lists. I've followed the steps from https://blogs.esri.com/esri/arcgis/2011/08/25/generating-a-choice-list-from-a-field/ but need to take it a step further and populate the 'HA' drop down list with the values in the 'HarvestArea' field that start with the 'ForestID'.
Any help on how to format this in the ToolValidator script (see below) would be much appreciated!
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
"""Setup arcpy and the list of tool parameters."""
self.params = arcpy.GetParameterInfo()
self.fcfield = (None, None)
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
"""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.value and self.params.value:
fc, col = str(self.params.value), str(self.params.value)
if self.fcfield != (fc, col):
self.fcfield = (fc, col)
self.params.filter.list = [str(val) for val in
for row in arcpy.SearchCursor(fc,
if self.params.value not in self.params.filter.list:
self.params.value = self.params.filter.list
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
Solved! Go to Solution.
Mr Burton i didn't know how else to contact you regarding a similar issue that i have. I have posted my issue in the following url: https://community.esri.com/thread/213736-select-by-many-attributes-and-then-zoom-to-selected .
I tried searching to find a solution but until today i haven't found or given a solution that actually works. If you could find the time and take a look at my request i would appreciate it.
I already tried to alter the Tool validator with my columns based on the solution provided in your answer and added the new script tool (without changing anything) also from your answer within the current toolbox that i had but didn't work.
Please i need your guidance.
Your code is very useful. Is it possible to publish this script tool as a web tool (in Portal for ArcGIS) and use it in geoprocessing widget in Web AppBuilder? I tried but only one value appears on the lists. Maybe I make a mistake somewhere...
I haven't worked with Portal, so I'm not sure how it would work as a web tool. I suggest that you post a new question and include a link to this one for reference. Can you provide a bit more about what you want your tool to do?
I would like my tool to work like yours but with different data. I made a scripting tool in ArcGIS Pro and it works. Now I would like to embed the tool in a web application using geoprocessing widget. I found out that this is not possible because script validation doesn't work in geoprocessin widget. Look at this: How to Implement Custom tool Validation for Geoprocessing Widget. I this case, probably the only solution is to create a custom widget using java script.
Unfortunately I don't have a simple solution. It seems to me that you need to download the "geoprocessing" widget and modify it using java script. Then you need to place the custom widget on the webserver.
Thanks for the reply!
Do you happen to know any specific library that can help implement validation for fields. I had some experience with WAB Dev edition in the past but I am No Pro.