<?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: Python Script to Set Fields to &amp;quot;Read Only&amp;quot; in ArcGIS Pro in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/1093503#M44962</link>
    <description>&lt;P&gt;Dear Laura,&lt;/P&gt;&lt;P&gt;I am running into the exact same issue. I was wondering if you've found a solution yet?&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 08:58:23 GMT</pubDate>
    <dc:creator>VinceDoelman</dc:creator>
    <dc:date>2021-08-30T08:58:23Z</dc:date>
    <item>
      <title>Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219830#M9662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm encountering a strange roadblock and was looking to see if anyone else has experienced this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to write a python script that will turn some of my&amp;nbsp;fields to "read only" within my ArcPro project. My current script that that I have written will turn all fields to "read only" for the sake of testing. I have added a message to double check the properties of the field to confirm that it has been set to "read only." However in my current project, my fields still show as unchecked for the "read only" property.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="498531" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/498531_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone else been able to configure a script that would allow fields to retain this setting in their project? I was thinking maybe it had something to do with saving my project? Below is a copy of my script. Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="comment token"&gt;# Set variables&lt;/SPAN&gt;
project &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Map'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
layer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; field &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;editable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;editable&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219830#M9662</guid>
      <dc:creator>LauraCarson</dc:creator>
      <dc:date>2021-12-11T10:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219831#M9663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&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;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You would have more luck using&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/alter-field-properties.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/alter-field-properties.htm"&gt;Alter Field—Data Management toolbox | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where you can alter field properties as well as field names&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2020 21:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219831#M9663</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-07-01T21:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219832#M9664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Dan for your response! Unfortunately the Alter Field tool from the Data Management toolbox does not change the read-only property.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jul 2020 12:06:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219832#M9664</guid>
      <dc:creator>LauraCarson</dc:creator>
      <dc:date>2020-07-10T12:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219833#M9665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My bad... I think critical things probably need to be set up during the creation phase&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jul 2020 15:23:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/219833#M9665</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-07-10T15:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/1093503#M44962</link>
      <description>&lt;P&gt;Dear Laura,&lt;/P&gt;&lt;P&gt;I am running into the exact same issue. I was wondering if you've found a solution yet?&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 08:58:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/1093503#M44962</guid>
      <dc:creator>VinceDoelman</dc:creator>
      <dc:date>2021-08-30T08:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python Script to Set Fields to "Read Only" in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/1235294#M62690</link>
      <description>&lt;P&gt;You can use the cim object to change the field visibility and editable properties&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic2551.html" target="_blank"&gt;CIMLayerAction Class—ArcGIS Pro&lt;/A&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;listOfEditableFields = ['field1', 'field2']&lt;BR /&gt;listOfVisibleFields = ['field1', 'field2', 'field3']&lt;/P&gt;&lt;P&gt;def main():&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;arprxFile = r"&amp;lt;path to aprx&amp;gt;"&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;aprx = arcpy.mp.ArcGISProject(arprxFile)&lt;BR /&gt;maps = aprx.listMaps()&lt;BR /&gt;for map in maps:&lt;/P&gt;&lt;P class="lia-indent-padding-left-60px"&gt;for lyr in map.listLayers():&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;desc = arcpy.Describe(lyr)&lt;BR /&gt;print(lyr.name)&lt;BR /&gt;l_cim = lyr.getDefinition('V2')&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;if desc.dataElement.dataType == "FeatureClass":&lt;/P&gt;&lt;P class="lia-indent-padding-left-120px"&gt;featureTable = l_cim.featureTable&lt;BR /&gt;for fieldDesc in featureTable.fieldDescriptions:&lt;/P&gt;&lt;P class="lia-indent-padding-left-150px"&gt;fieldDesc.visible = False&lt;BR /&gt;fieldDesc.readOnly = False&lt;BR /&gt;for visibleFieldName in listOfVisibleFields:&lt;/P&gt;&lt;P class="lia-indent-padding-left-180px"&gt;if fieldDesc.fieldName == visibleFieldName:&lt;BR /&gt;fieldDesc.visible = True&lt;/P&gt;&lt;P class="lia-indent-padding-left-150px"&gt;for editableFieldName in listOfEditableFields:&lt;/P&gt;&lt;P class="lia-indent-padding-left-180px"&gt;if fieldDesc.fieldName == editableFieldName:&lt;BR /&gt;fieldDesc.readOnly = True&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;lyr.setDefinition(l_cim)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;del aprx&lt;BR /&gt;print("Completed")&lt;BR /&gt;if __name__ == '__main__':&lt;BR /&gt;main()&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 06:38:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-to-set-fields-to-quot-read-only-quot/m-p/1235294#M62690</guid>
      <dc:creator>stevetaylor_perth</dc:creator>
      <dc:date>2022-11-28T06:38:20Z</dc:date>
    </item>
  </channel>
</rss>

