[GIS] How to build SQL Expressions in ArcGIS 10.1 Python script tool dialog

arcgis-10.1arcgis-desktoparcpyparameterspython

I've made a python tool that requires the user to establish which state to select within an input's table (the "Prepared Footprint"). However, once the user drops in the layer and tries to write the SQL statement to select the state which is contained in the state field of the Prepared Footprint, there are no available fields to select from.

enter image description here

Is there some option within the properties of the python script tool that will allow the Query Builder to populate the fields and attributes from the input layer like the native Select by Attributes in ArcMap? If not, how might I code this into my source script to feed fields and their attributes to the Query Builder of the "State" parameter?

(experience level with building tools: Beginner)


EDIT:
Here's a screenshot of the tool's parameters. When I select "State" and try to change the "Obtained from" paramter property nothing happens. There's no drop down, no cursor, nothing but a highlighted row for "Obtained from". Has anyone ever had this problem before?

enter image description here


EDIT:
Found the problem. A "Layer" data type cannot be used as the input for "Obtained from". Feature Layer works instead for this case.

enter image description here

Best Answer

When you define the parameters for your script. For the "State" parameter, you have to set the "obtained from" parameter properties to "Prepared Footprint".

Related Question