ArcPy – How to Restrict Parameter Value Lists Based on Another’s Chosen Value in ArcGIS Pro

arcgis-proarcpychoice-listparameterspython-toolbox

I have a script loaded as a toolbox into ArcGIS Pro. It has two multi-value string parameters.

Is there a way to restrict the second parameter's list against the first?

For example, if a user picks "New Jersey" from the first list, their options would be restricted to "North" or "South." But if they chose "New York" then instead the second parameter would list "Long Island", "Bronx", and "Manhattan."

As I currently have it, there's just a long list in the second parameter and its not linked to or associated with the first. I'd prefer to have this as one tool rather than create multiple nearly identical tools for different regions of a business.

Best Answer

To do this I think you should investigate using a Filter class:

The filter object allows you to specify the choices available for a parameter.

On that page of the documentation there is:

An example where the value list filter in the second parameter changes based on the shape type found in the first parameter, a feature class.

You could adjust that code to be an example where the value list filter in the second parameter changes based on the value chosen in the first parameter.

Related Question