<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Use Arcpy to run a definition query on a standalone table in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/use-arcpy-to-run-a-definition-query-on-a/m-p/1382990#M78871</link>
    <description>&lt;P&gt;I am wanting to create a definition query on a standalone table using arcpy. I have a way set up to do it on a layer file but because a table isn't a layer file this code obviously doesn't work.&lt;/P&gt;&lt;P&gt;The line of code that is bold is where things go wrong, because its not a layer. Is there a function similar to map_obj.listLayers for tables that I am missing?&lt;/P&gt;&lt;PRE&gt;# Access the map and the layer&lt;BR /&gt;map_obj = aprx.listMaps(map_name)[0]&lt;BR /&gt;&lt;STRONG&gt;layer_obj = map_obj.listLayers(layer_name)[0]&lt;/STRONG&gt;&lt;BR /&gt;# Set a simple definition query&lt;BR /&gt;definition_query = f"{field_name} = '{query_value}'"&lt;BR /&gt;layer_obj.definitionQuery = definition_query&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2024 18:29:31 GMT</pubDate>
    <dc:creator>edward33</dc:creator>
    <dc:date>2024-02-15T18:29:31Z</dc:date>
    <item>
      <title>Use Arcpy to run a definition query on a standalone table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/use-arcpy-to-run-a-definition-query-on-a/m-p/1382990#M78871</link>
      <description>&lt;P&gt;I am wanting to create a definition query on a standalone table using arcpy. I have a way set up to do it on a layer file but because a table isn't a layer file this code obviously doesn't work.&lt;/P&gt;&lt;P&gt;The line of code that is bold is where things go wrong, because its not a layer. Is there a function similar to map_obj.listLayers for tables that I am missing?&lt;/P&gt;&lt;PRE&gt;# Access the map and the layer&lt;BR /&gt;map_obj = aprx.listMaps(map_name)[0]&lt;BR /&gt;&lt;STRONG&gt;layer_obj = map_obj.listLayers(layer_name)[0]&lt;/STRONG&gt;&lt;BR /&gt;# Set a simple definition query&lt;BR /&gt;definition_query = f"{field_name} = '{query_value}'"&lt;BR /&gt;layer_obj.definitionQuery = definition_query&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 18:29:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/use-arcpy-to-run-a-definition-query-on-a/m-p/1382990#M78871</guid>
      <dc:creator>edward33</dc:creator>
      <dc:date>2024-02-15T18:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Use Arcpy to run a definition query on a standalone table</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/use-arcpy-to-run-a-definition-query-on-a/m-p/1383101#M78891</link>
      <description>&lt;P&gt;the Table class in the mapping module shows...&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/table-class.htm" target="_blank"&gt;Table—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are two ways tables can be referenced in a script for use in a project. To reference tables already in a project, use the listTables method on the Map class. To reference tables directly from a workspace, use the Table function.&lt;/P&gt;&lt;P&gt;definitionQuery&lt;BR /&gt;(Read and Write)&lt;BR /&gt;Provides the ability to get or set a tables's definition query.&amp;nbsp; &amp;nbsp; &amp;nbsp;String&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 20:38:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/use-arcpy-to-run-a-definition-query-on-a/m-p/1383101#M78891</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-02-15T20:38:33Z</dc:date>
    </item>
  </channel>
</rss>

