<?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 Re: Delete definitionQuery different from 2.83 to 2.9 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161262#M64283</link>
    <description>&lt;P&gt;Sorry found some code elsewhere.&amp;nbsp; The following will remove all definition queries from a layer.&amp;nbsp; In this case the layer is called "Anno0200Scale" as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;Map = aprx.activeMap&lt;BR /&gt;Lyr = Map.listLayers("Anno0200Scale")[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Lyr_cim = Lyr.getDefinition('V2')&lt;/P&gt;&lt;P&gt;fTab = Lyr_cim.featureTable&lt;BR /&gt;fTab.definitionFilterChoices = None&lt;/P&gt;&lt;P&gt;Lyr.setDefinition(Lyr_cim)&lt;/P&gt;&lt;P&gt;I am not sure if this is the best way to do it but it does it.&amp;nbsp; Please let me know if there are better ways.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 17:17:02 GMT</pubDate>
    <dc:creator>DeanAnderson2</dc:creator>
    <dc:date>2022-04-05T17:17:02Z</dc:date>
    <item>
      <title>Delete definitionQuery different from 2.83 to 2.9</title>
      <link>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161221#M64281</link>
      <description>&lt;P&gt;Been using 2.8 for a bit and have had no problem clearing definition queries with the following code.&amp;nbsp; If TurnQueryOn is true it sets the definition query. If it is false it sets definition query to None.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;if TurnQueryOn: &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RecordWhereClause = "CreatedByRecord = " + "'" + RecordNumber + "'"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for FilterLayer in FilterLayers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapFilterLyr = Map.listLayers(FilterLayer)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if mapFilterLyr.isFeatureLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapFilterLyr.definitionQuery = RecordWhereClause &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for FilterLayer in FilterLayers: &amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapFilterLyr = Map.listLayers(FilterLayer)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if mapFilterLyr.isFeatureLayer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapFilterLyr.definitionQuery = None&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I just upgraded to 2.9 (I still have a machine 2.83 so was able to double check).&amp;nbsp; But the definition queries are no longer being deleted but just turns them to "inactive".&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DeanAnderson2_0-1649175706326.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/38165i514E9BA177D16D04/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DeanAnderson2_0-1649175706326.png" alt="DeanAnderson2_0-1649175706326.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there something I am doing wrong?&amp;nbsp; (I have seen other posts for this in the past and they appear to operate the same as mine does in 2.83.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 16:24:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161221#M64281</guid>
      <dc:creator>DeanAnderson2</dc:creator>
      <dc:date>2022-04-05T16:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Delete definitionQuery different from 2.83 to 2.9</title>
      <link>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161246#M64282</link>
      <description>&lt;P&gt;2.9&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layer-class.htm" target="_blank"&gt;Layer—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2.8&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/mapping/layer-class.htm" target="_blank"&gt;Layer—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;differences in the descriptions can be compared between the two&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 16:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161246#M64282</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-04-05T16:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Delete definitionQuery different from 2.83 to 2.9</title>
      <link>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161262#M64283</link>
      <description>&lt;P&gt;Sorry found some code elsewhere.&amp;nbsp; The following will remove all definition queries from a layer.&amp;nbsp; In this case the layer is called "Anno0200Scale" as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;Map = aprx.activeMap&lt;BR /&gt;Lyr = Map.listLayers("Anno0200Scale")[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Lyr_cim = Lyr.getDefinition('V2')&lt;/P&gt;&lt;P&gt;fTab = Lyr_cim.featureTable&lt;BR /&gt;fTab.definitionFilterChoices = None&lt;/P&gt;&lt;P&gt;Lyr.setDefinition(Lyr_cim)&lt;/P&gt;&lt;P&gt;I am not sure if this is the best way to do it but it does it.&amp;nbsp; Please let me know if there are better ways.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 17:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-definitionquery-different-from-2-83-to-2-9/m-p/1161262#M64283</guid>
      <dc:creator>DeanAnderson2</dc:creator>
      <dc:date>2022-04-05T17:17:02Z</dc:date>
    </item>
  </channel>
</rss>

