<?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: CIM FieldDescriptions is not accessible for some layers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1359476#M69383</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;1) Is there any Python workaround that would fix accessibility of&amp;nbsp; CIM FieldDescriptions for layers that don't have them?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;ESRI documentation promotes a hack:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;If the layer does not have field descriptions, it calls the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;AlterField&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;function on the first field, which forces the information into the CIM without making changes to the field.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AlterField(lyr, lyrFld.name) #Force CIM update  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems that the efficiency gain from not generating this information is less important that offering a predictable developer experience from the CIM API. I wish fieldDescriptions was always there.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2023 00:10:33 GMT</pubDate>
    <dc:creator>PhilLarkin1</dc:creator>
    <dc:date>2023-12-12T00:10:33Z</dc:date>
    <item>
      <title>CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1332453#M68760</link>
      <description>&lt;P&gt;Environment: ArcGIS Pro 3.1.2&lt;/P&gt;&lt;P&gt;Python CIM is a great way to modify field properties for a layer, as described &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm" target="_blank" rel="noopener"&gt;here&amp;nbsp;&lt;/A&gt; (example 2 - Modify field properties). Among others, it seems like an easy way to turn field visibility on and off for layers in project without all the complication of using FieldInfo (&lt;A href="https://community.esri.com/t5/python-questions/turn-off-fields-with-python/m-p/403316#M31754" target="_blank" rel="noopener"&gt;example&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Well, at least in theory. In reality it turned out that FieldDescriptions array is not exposed in some cases. And the simplest scenario is just dragging any feature class into the map. Let's say we have point TestFeature in File Geodatabase which have standard fields OBJECTID, Shape and additional field called TestField.&lt;/P&gt;&lt;P&gt;Following code will not find any fields in this given scenario for the "fresh" layer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;m = arcpy.mp.ArcGISProject('current').activeMap
lyr = m.listLayers('TestFeature')[0] 
cim_lyr = lyr.getDefinition('V3') #Neither V2 nor V3 works
print (f"Number of fields: {len(cim_lyr.featureTable.fieldDescriptions)}")
for fd in cim_lyr.featureTable.fieldDescriptions:
    print (fd.fieldName) #should print fields names&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the result is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Number of fields: 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I make any changes to layer Fields properties manually (by going to DataDesign -&amp;gt; Fields of TestFeature &lt;STRONG&gt;layer &lt;/STRONG&gt;and making any changes and saving them) , FieldDescriptions are "fixed" and the result of above script is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Number of fields: 3
OBJECTID
Shape
TestField&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This behavior is also confirmed by analyzing saved layer files (lyrx, which in fact is JSON) before and after saving changes in DataDesign/Fields. Before saving JSON doesn't contain FieldDescriptions in CIMFeatureTable:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SzymAdamowski_0-1695739891609.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81650i47CDC400902AA9E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SzymAdamowski_0-1695739891609.png" alt="SzymAdamowski_0-1695739891609.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After saving (any, even not real) changes in Fields (making sure that Fields editor is started from Layer, not from Feature Class)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SzymAdamowski_1-1695740009155.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81651iB42A48EB73B7B62C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SzymAdamowski_1-1695740009155.png" alt="SzymAdamowski_1-1695740009155.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;CIMFieldDescriptions appears in lyrx/JSON:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SzymAdamowski_2-1695740075319.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81652i5AD5B65F9EE402B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SzymAdamowski_2-1695740075319.png" alt="SzymAdamowski_2-1695740075319.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;1) Is there any Python workaround that would fix accessibility of&amp;nbsp; CIM FieldDescriptions for layers that don't have them? (What I've shown is manual workaround, which for many reasons is impractical in my case).&lt;/P&gt;&lt;P&gt;2) If it is a bug (I suppose so), could it be fixed in next ArcGIS Pro versions?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 15:39:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1332453#M68760</guid>
      <dc:creator>SzymAdamowski</dc:creator>
      <dc:date>2023-09-26T15:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1359476#M69383</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;1) Is there any Python workaround that would fix accessibility of&amp;nbsp; CIM FieldDescriptions for layers that don't have them?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;ESRI documentation promotes a hack:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;If the layer does not have field descriptions, it calls the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;AlterField&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;function on the first field, which forces the information into the CIM without making changes to the field.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.AlterField(lyr, lyrFld.name) #Force CIM update  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Seems that the efficiency gain from not generating this information is less important that offering a predictable developer experience from the CIM API. I wish fieldDescriptions was always there.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 00:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1359476#M69383</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2023-12-12T00:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1359480#M69384</link>
      <description>&lt;P&gt;I should note this hacky solution doesn't seem to work at Pro 3.2.0 when run in a Script Tool.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 00:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1359480#M69384</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2023-12-12T00:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1398265#M70091</link>
      <description>&lt;P&gt;Well, if you add the bottom 2 lines after the AlterField, it works for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcpy.management.AlterField(l, field_name, field_name)&amp;nbsp;&lt;/P&gt;&lt;P&gt;l_cim = l.getDefinition('V2')&lt;BR /&gt;l.setDefinition(l_cim)&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 05:58:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1398265#M70091</guid>
      <dc:creator>Jennya</dc:creator>
      <dc:date>2024-03-20T05:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1485135#M70722</link>
      <description>&lt;P&gt;Works for me as well (in Pro 3.2).Thx&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 09:28:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1485135#M70722</guid>
      <dc:creator>SzymAdamowski</dc:creator>
      <dc:date>2024-06-05T09:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: CIM FieldDescriptions is not accessible for some layers</title>
      <link>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1522277#M71257</link>
      <description>&lt;P&gt;I'm glad I found this! The hack works at 3.3 as well.&amp;nbsp; It seems the layer object could use a "populateCim" method...&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 15:31:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-fielddescriptions-is-not-accessible-for-some/m-p/1522277#M71257</guid>
      <dc:creator>Pukawai</dc:creator>
      <dc:date>2024-08-15T15:31:49Z</dc:date>
    </item>
  </channel>
</rss>

