<?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 NameError: The attribute 'definitionQuery' is not supported on this instance of Layer. in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/nameerror-the-attribute-definitionquery-is-not/m-p/1242114#M63540</link>
    <description>&lt;P&gt;I use a tool within a custom Python toolbox to set definition queries on multiple layers that have similar schemas that I need to filter for additional processing. Here is the execute() part of the code for the tool:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;execute&lt;/SPAN&gt;(self, params, messages):&lt;BR /&gt;    &lt;SPAN&gt;# define parameters&lt;BR /&gt;&lt;/SPAN&gt;    eoid &lt;SPAN&gt;= &lt;/SPAN&gt;params[&lt;SPAN&gt;0&lt;/SPAN&gt;].valueAsText&lt;BR /&gt;    specid &lt;SPAN&gt;= &lt;/SPAN&gt;params[&lt;SPAN&gt;1&lt;/SPAN&gt;].valueAsText&lt;BR /&gt;&lt;BR /&gt;    aprx &lt;SPAN&gt;= &lt;/SPAN&gt;arcpy.mp.ArcGISProject(&lt;SPAN&gt;"CURRENT"&lt;/SPAN&gt;)&lt;BR /&gt;    m &lt;SPAN&gt;= &lt;/SPAN&gt;aprx.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"eo_*"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"EO_ID = {}"&lt;/SPAN&gt;.format(eoid)&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"CPP *"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"EO_ID = &lt;/SPAN&gt;&lt;SPAN&gt;{}&lt;/SPAN&gt;&lt;SPAN&gt; OR EO_ID IS NULL"&lt;/SPAN&gt;.format(eoid)&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"spec filter *"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"SpecID LIKE '{}%'"&lt;/SPAN&gt;.format(specid)&lt;/PRE&gt;&lt;P&gt;I've been using this tool for years with no issues. Lately, the tool has been failing with the following error code:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;NameError: The attribute 'definitionQuery' is not supported on this instance of Layer.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;It will apply the definition query on some of the layers, but not others and seems inconsistent for which layers the definition query is applied. Here's a screen clip of the layers in my Pro project:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MollyMoore_0-1671219083717.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58796iA6F5DA5D41FA4D83/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MollyMoore_0-1671219083717.png" alt="MollyMoore_0-1671219083717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyone have any ideas for why this is happening, but didn't seem to be an issue in the past?&lt;/P&gt;&lt;P&gt;This looks related to the issue here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/the-attribute-name-is-not-supported-on-an-instance/td-p/1061506" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/python-questions/the-attribute-name-is-not-supported-on-an-instance/td-p/1061506&lt;/A&gt;&amp;nbsp;but these layers do support definition queries (either manually or in the past when it worked through Python).&lt;/P&gt;&lt;P&gt;The layers are from feature services. I'm currently using Pro 2.9.5 and also tested in 2.9.0. We are currently dealing with another bug that is prohibiting us from upgrading to 3.0.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2022 20:43:41 GMT</pubDate>
    <dc:creator>MollyMoore</dc:creator>
    <dc:date>2022-12-16T20:43:41Z</dc:date>
    <item>
      <title>NameError: The attribute 'definitionQuery' is not supported on this instance of Layer.</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/nameerror-the-attribute-definitionquery-is-not/m-p/1242114#M63540</link>
      <description>&lt;P&gt;I use a tool within a custom Python toolbox to set definition queries on multiple layers that have similar schemas that I need to filter for additional processing. Here is the execute() part of the code for the tool:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;execute&lt;/SPAN&gt;(self, params, messages):&lt;BR /&gt;    &lt;SPAN&gt;# define parameters&lt;BR /&gt;&lt;/SPAN&gt;    eoid &lt;SPAN&gt;= &lt;/SPAN&gt;params[&lt;SPAN&gt;0&lt;/SPAN&gt;].valueAsText&lt;BR /&gt;    specid &lt;SPAN&gt;= &lt;/SPAN&gt;params[&lt;SPAN&gt;1&lt;/SPAN&gt;].valueAsText&lt;BR /&gt;&lt;BR /&gt;    aprx &lt;SPAN&gt;= &lt;/SPAN&gt;arcpy.mp.ArcGISProject(&lt;SPAN&gt;"CURRENT"&lt;/SPAN&gt;)&lt;BR /&gt;    m &lt;SPAN&gt;= &lt;/SPAN&gt;aprx.listMaps(&lt;SPAN&gt;"Map"&lt;/SPAN&gt;)[&lt;SPAN&gt;0&lt;/SPAN&gt;]&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"eo_*"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"EO_ID = {}"&lt;/SPAN&gt;.format(eoid)&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"CPP *"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"EO_ID = &lt;/SPAN&gt;&lt;SPAN&gt;{}&lt;/SPAN&gt;&lt;SPAN&gt; OR EO_ID IS NULL"&lt;/SPAN&gt;.format(eoid)&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;lyr &lt;SPAN&gt;in &lt;/SPAN&gt;m.listLayers(&lt;SPAN&gt;"spec filter *"&lt;/SPAN&gt;):&lt;BR /&gt;        lyr.definitionQuery &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;"SpecID LIKE '{}%'"&lt;/SPAN&gt;.format(specid)&lt;/PRE&gt;&lt;P&gt;I've been using this tool for years with no issues. Lately, the tool has been failing with the following error code:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;NameError: The attribute 'definitionQuery' is not supported on this instance of Layer.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;It will apply the definition query on some of the layers, but not others and seems inconsistent for which layers the definition query is applied. Here's a screen clip of the layers in my Pro project:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MollyMoore_0-1671219083717.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58796iA6F5DA5D41FA4D83/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MollyMoore_0-1671219083717.png" alt="MollyMoore_0-1671219083717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyone have any ideas for why this is happening, but didn't seem to be an issue in the past?&lt;/P&gt;&lt;P&gt;This looks related to the issue here:&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/the-attribute-name-is-not-supported-on-an-instance/td-p/1061506" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/python-questions/the-attribute-name-is-not-supported-on-an-instance/td-p/1061506&lt;/A&gt;&amp;nbsp;but these layers do support definition queries (either manually or in the past when it worked through Python).&lt;/P&gt;&lt;P&gt;The layers are from feature services. I'm currently using Pro 2.9.5 and also tested in 2.9.0. We are currently dealing with another bug that is prohibiting us from upgrading to 3.0.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 20:43:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/nameerror-the-attribute-definitionquery-is-not/m-p/1242114#M63540</guid>
      <dc:creator>MollyMoore</dc:creator>
      <dc:date>2022-12-16T20:43:41Z</dc:date>
    </item>
  </channel>
</rss>

