Select to view content in your preferred language

Access the "SQL Expression" parameters and add custom filter lists

1212
11
09-21-2023 09:35 AM
xavro
by
New Contributor II

Hello, being a beginner on arcpy and in the design of my first script tool in arcgis pro

I want to know if it is possible to access the "SQL Expression" parameters with python and add lists of personalized filters in order to create personal SQL queries.

Thank you very much for your help.

 

0 Kudos
11 Replies
JohannesLindner
MVP Frequent Contributor

No. The SQL Expression parameter requires a dependency.

You don't have to set that dependency in the parameter editor. You can also use the parameter.parameterDependencies property in the validation:

class ToolValidator:
    def __init__(self):
        self.params = arcpy.GetParameterInfo()

    def updateParameters(self):
        self.params[1].parameterDependencies = ["layer"]

 

But for the tool to fill out the lists of field names and values, the parameter needs a dependency.

 

 

If you don't want to do it that way, you could use a string parameter. Users can then simply input their query (or you can prepare a dropdown).


Have a great day!
Johannes
xavro
by
New Contributor II

Thanks, I was able to access all my settings and do my search tasks while running the script. However, for each value change in my searches, I would like to delete my previous query definition, can I do that?

0 Kudos