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.
#xavro, here's a link that will get you started. https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/specifying-a-query.htm
A technique I used early on when I was learning about using Python with ArcGIS was to run the tool and, from the Geoprocessing History panel, drag the process to the Python window. This showed me all the parameters that had been used on that run and how they were formatted.
The ultimate source for seeing how the code should be used is the arcpy Python documentation. SearchCursor—ArcGIS Pro | Documentation
Thank you for your answers, but I think we misunderstood or maybe it's me...but the goal is to modify the list of filters available in the "SQL expression" tool. see my screenshot.
Here's an earlier post "Programmatically select layer definition query" found here https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-select-layer-definitio...
See also - "Delete vs deactivate layer definition query"- https://community.esri.com/t5/python-questions/delete-vs-deactivate-layer-definition-query/m-p/13136...
Thank you, but I know and have already seen everything relating to layer definition requests. The purpose of this tool is to have the possibility of carrying out searches on attributes common to several layers and then defining definition queries on the corresponding layers.
I would like to use initializeParameters(self): to populate my filter lists.
A bit like we can do in a “Chaine” data type via self.params[3].filter.list = category
It may be better if you posted some sort of sample code so we can figure out exactly what you're trying for.
I think, though, that you should investigate updateParameters() to change your filter list.
You have to set the dependency of the Sql Expression parameter to a layer/feature class parameter:
Then it will grab the possible fields and values from that parameter.
Without a selected layer:
With a selected layer:
Thanks, but is it possible to edit or create these fields/value without feature layer dependencies ?
With updateParameters() or initializeParameters() ?