<?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: Editing layer field properties in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827667#M405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Wes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the property I would like to change is the one outlined in red:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="layer_field_properties.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/163937_layer_field_properties.png" style="width: 620px; height: 486px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you change this property here and then share the layer as feature service, the server will keep it disabling the editing of the field also if you enable the update capability.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 Jan 2016 08:41:46 GMT</pubDate>
    <dc:creator>DamianoMorosi1</dc:creator>
    <dc:date>2016-01-04T08:41:46Z</dc:date>
    <item>
      <title>Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827662#M400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would modify the properties of all layers in an mxd setting, for instance, all the fields as non editable.&lt;/P&gt;&lt;P&gt;The following script &lt;SPAN style="text-decoration: underline;"&gt;seems&lt;/SPAN&gt; to work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;import arcpy&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;mxd = arcpy.mapping.MapDocument('path-to-mxd')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;layers = arcpy.mapping.ListLayers(mxd,"*",df)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;for lyr in layers:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Working on layer: " + lyr.name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = arcpy.ListFields(lyr.dataSource)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in fields:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f.editable = False&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;mxd.save()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It runs without errors, prints all the layer names but when I open the mxd nothing has changed, the fields are still editable. By the way the mxd IS saved, I just see a new timestamp in the "last modified" property of the file.&lt;/P&gt;&lt;P&gt;Am I missing something?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Damiano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Dec 2015 16:58:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827662#M400</guid>
      <dc:creator>DamianoMorosi1</dc:creator>
      <dc:date>2015-12-30T16:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827663#M401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;perhaps this is important&lt;/P&gt;&lt;P style="font-size: 0.875rem; margin-bottom: 1.71429em;"&gt;Updating a field property only updates the field object, no changes are made to the actual field in the table or feature class.&lt;BR /&gt;from &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/field.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/field.htm"&gt;Field—Help | ArcGIS for Desktop&lt;/A&gt; &lt;BR /&gt;&lt;SPAN style="font-size: 0.875rem;"&gt;implying that there is no persistence of the state outside of the field instance.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Dec 2015 17:11:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827663#M401</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-30T17:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827664#M402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't find how to change the field property "Make field read only" but maybe you or someone else knows. If you can change that property it will make the field non-editable.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/163073_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2015 13:46:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827664#M402</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-12-31T13:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827665#M403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they are standalone files, this property doesn't persist outside the project &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2015 14:09:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827665#M403</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-12-31T14:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827666#M404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would need to leverage ArcObjects to accomplish this against an existing layer object. I'd assume that the code needed would be similar to the following snippet I put together.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;static void MakeFieldReadonly(ESRI.ArcGIS.Carto.ILayer layer, string fieldname)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get the fields for the layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var layerfields = layer as ESRI.ArcGIS.Carto.ILayerFields;


&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i = 0; i &amp;lt; layerfields.FieldCount; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set field readonly property to true if field matches needed field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (layerfields.Field&lt;I&gt;.Name.Equals(fieldname, System.StringComparison.InvariantCultureIgnoreCase))&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (layerfields.FieldInfo&lt;I&gt; as ESRI.ArcGIS.Geodatabase.IFieldInfo3).Readonly = true;&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;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I understand the readonly property is only valid within the client. As such, I don't believe that you'd ever be able to persist this value within the geodatabase without making the entire feature class readonly. If it were possible to set this value then I'd assume that there'd be a method available within IClassSchemaEdit, but so far I haven't seen a method available that would allow that. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:58:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827666#M404</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2021-12-12T09:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827667#M405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Wes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the property I would like to change is the one outlined in red:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="layer_field_properties.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/163937_layer_field_properties.png" style="width: 620px; height: 486px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you change this property here and then share the layer as feature service, the server will keep it disabling the editing of the field also if you enable the update capability.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2016 08:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827667#M405</guid>
      <dc:creator>DamianoMorosi1</dc:creator>
      <dc:date>2016-01-04T08:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827668#M406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Freddie, I'll give it a try. However, I would only like to persist the changes in the mxd, not in the geodatabase. See the screenshot above and my reply to Wes on this. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2016 08:53:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827668#M406</guid>
      <dc:creator>DamianoMorosi1</dc:creator>
      <dc:date>2016-01-04T08:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827669#M407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I indicated earlier, it persists within the arcmap session and project, the read-only preservation is not kept when the layer is added to another project&lt;/P&gt;&lt;P&gt;&lt;IMG alt="read_only_fields.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/163938_read_only_fields.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2016 09:49:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827669#M407</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-04T09:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827670#M408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course! But with Python also this kind of persistence seems to be not achievable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2016 11:43:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827670#M408</guid>
      <dc:creator>DamianoMorosi1</dc:creator>
      <dc:date>2016-01-04T11:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827671#M409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is correct.&amp;nbsp; I guess we are commenting on the concept of 'persistence'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jan 2016 14:40:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827671#M409</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-04T14:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827672#M410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you come up with a solution to this?&lt;/P&gt;&lt;P&gt;I too have fields that I would like to change the editable value for. In my case I need to make a read only field into an editable field.&lt;/P&gt;&lt;P&gt;The change can be made in the field properties of the layer without changing the actual feature class.&amp;nbsp;I know this because I add the feature class to a clean map and the fields are set to NOT read only.&lt;/P&gt;&lt;P&gt;Is this possible to iterate over the entire map and change all fields to "editable = true" with python?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 02:29:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827672#M410</guid>
      <dc:creator>jameshickey</dc:creator>
      <dc:date>2017-02-13T02:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827673#M411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;examine the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/field.htm"&gt;arcpy field section&lt;/A&gt; ... it is editable&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;editable (Read and Write) ... The editable state: True if the field is editable.&amp;nbsp; ...Boolean&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 02:48:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827673#M411</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-13T02:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Editing layer field properties</title>
      <link>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827674#M412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello and thanks for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I saw that and have been working with it for a couple of hours now.&lt;/P&gt;&lt;P&gt;Still cant seem to access the layers in the map specifically.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
#Set env workspace
mxd = arcpy.mapping.MapDocument(r"C:\Users\billid\Desktop\WaterUtilityNetwork\WaterSystem.mxd")

#Get layers
for lyr in arcpy.mapping.ListLayers(mxd):
 #Get fields
 fields = arcpy.ListFields(lyr)
 for field in fields:
 &amp;nbsp;&amp;nbsp;&amp;nbsp;print(field)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just get this error.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Traceback (most recent call last):&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; File "D:\PythonWorkingFolder\GIS_Python\ListLayers.py", line 8, in &amp;lt;module&amp;gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; fields = arcpy.ListFields(lyr)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 1138, in ListFields&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; return gp.listFields(dataset, wild_card, field_type)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", line 346, in listFields&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt; self._gp.ListFields(*gp_fixargs(args, True)))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IOError: "Water System" does not exist &amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;ListFields is supposed to take a string. ListLayers returns&amp;nbsp;&amp;lt;class 'arcpy._mapping.Layer'&amp;gt; not a string&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that "Water System" is a layer group, but even when I un-group all the layers it just tells me the first layer doesn't exist. I'm guessing it is because it's not a string.&lt;/P&gt;&lt;P&gt;I don't want to work on the data source as it is already set "editable &amp;nbsp;= true" the map layer properties have it set to false and I would like to change the map and then I can overwrite the .lyr file. Yes I can do it manually but I have many maps and need to check all the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for your feed back. &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: I suppose if i could turn the layer names into text I could make a list out of them....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:58:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/editing-layer-field-properties/m-p/827674#M412</guid>
      <dc:creator>jameshickey</dc:creator>
      <dc:date>2021-12-12T16:58:09Z</dc:date>
    </item>
  </channel>
</rss>

