Table of Contents
The Video
Introduction
You are creating an ArcGIS Pro custom tool with ArcPy and you want to allow the user to select from a dropdown list or type in free-text for the input. This is now possible out-of-the-box and requires a small bit of tinkering with the tool properties Validation tab.
ArcGIS Pro Definition Query Masterclass with ArcPy & Python
Free on YouTube! Witness the power of Definition Queries in ArcGIS Pro through this comprehensive course that dives managing and utilizing definition queries with spatial data using ArcPy and Python scripting. In this course, we will focus exclusively on Definition Queries, covering their creation, modification, and application through hands-on exercises and real-world scenarios.
In your custom script tool. Add the below to the updateMessages() function in the Validation tab. This will clear the error message you receive when you apply free-text to an input that has a list of values as a dropdown. Check out the video above for more information.
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 self.params[0].value:
self.params[0].clearMessage()
return
If you’ve found these blogs helpful and would like to support the project, please consider making a donation. All learning material is provided free of charge to help GIS professionals, students, and developers learn ArcPy, the ArcGIS API for Python, ArcGIS Pro, and ArcGIS Online. Donations help cover website hosting, software licensing, domain costs, and the time involved in creating and maintaining tutorials, courses, and learning resources. Your support helps keep this content freely available to everyone and allows new courses and materials to be developed for the GIS community. If the content has helped you solve a problem, learn a new skill, or advance your career, please consider supporting the project with a donation. Every contribution, no matter the size, is greatly appreciated.