<?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: Update Properties not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-properties-not-working/m-p/1326912#M68554</link>
    <description>&lt;P&gt;I've been wrestling with that method call all week.&amp;nbsp; I think passing a dictionary in to it is getting me closer. I will try to post some actual code here later. Basically I read the existing properties, modify, then write back out.&lt;/P&gt;&lt;P&gt;I iterate over all the maps in an APRX, then iterate over the layers in each map.&amp;nbsp; Then read properties for each layer, modify, write to map, then save the APRX.&lt;/P&gt;&lt;P&gt;It's not perfect yet but it's getting better.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;properties = None
try:
  properties = lyr.connectionProperties
except Exception as e:
  messages.addMessage(f"    no connectionProperties ?? {e}")
  continue


Now I have properties, I can change them, for example, 

properties['connection_info']['server'] = server
properties['connection_info']['instance'] = f"sde:sqlserver:{server};MULTISUBNETFAILOVER=YES"
lyr.updateConnectionProperties(None, # Careful! This replaces ANYTHING 
                               properties,
                               auto_update_joins_and_relates = True)

Lots of code right now surrounds these blocks, dumping out messages
and testing for layer types to be ignored... not showing any of that here.&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 08 Sep 2023 18:04:41 GMT</pubDate>
    <dc:creator>Brian_Wilson</dc:creator>
    <dc:date>2023-09-08T18:04:41Z</dc:date>
    <item>
      <title>Update Properties not working</title>
      <link>https://community.esri.com/t5/python-questions/update-properties-not-working/m-p/1326898#M68552</link>
      <description>&lt;P&gt;I am trying to update the connection properties of a group layer onto a new geodatabase, and even though the script runs, the data sources end up being broken. I was wondering what I can do to fix this?&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;lyr&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;group_layer&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt; &lt;SPAN&gt;lyr&lt;/SPAN&gt;&lt;SPAN&gt;.supports(&lt;/SPAN&gt;&lt;SPAN&gt;"CONNECTIONPROPERTIES"&lt;/SPAN&gt;&lt;SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&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;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;#Update properties function&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;lyr&lt;/SPAN&gt;&lt;SPAN&gt;.updateConnectionProperties(&lt;/SPAN&gt;&lt;SPAN&gt;""&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;curr_gdb&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This is what the data source is supposed to look like for the layer:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Update Properties.png" style="width: 613px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80228i434DFD65FD995E1D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Update Properties.png" alt="Update Properties.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, even though it successfully updates connective properties to the certain geodatabase I want, this is what the data source looks like for the layer when I run the code:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Update Properties Error.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80229iE59D14C4542F3654/image-size/large?v=v2&amp;amp;px=999" role="button" title="Update Properties Error.png" alt="Update Properties Error.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 08 Sep 2023 17:48:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-properties-not-working/m-p/1326898#M68552</guid>
      <dc:creator>AnjeliDubey</dc:creator>
      <dc:date>2023-09-08T17:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Update Properties not working</title>
      <link>https://community.esri.com/t5/python-questions/update-properties-not-working/m-p/1326912#M68554</link>
      <description>&lt;P&gt;I've been wrestling with that method call all week.&amp;nbsp; I think passing a dictionary in to it is getting me closer. I will try to post some actual code here later. Basically I read the existing properties, modify, then write back out.&lt;/P&gt;&lt;P&gt;I iterate over all the maps in an APRX, then iterate over the layers in each map.&amp;nbsp; Then read properties for each layer, modify, write to map, then save the APRX.&lt;/P&gt;&lt;P&gt;It's not perfect yet but it's getting better.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;properties = None
try:
  properties = lyr.connectionProperties
except Exception as e:
  messages.addMessage(f"    no connectionProperties ?? {e}")
  continue


Now I have properties, I can change them, for example, 

properties['connection_info']['server'] = server
properties['connection_info']['instance'] = f"sde:sqlserver:{server};MULTISUBNETFAILOVER=YES"
lyr.updateConnectionProperties(None, # Careful! This replaces ANYTHING 
                               properties,
                               auto_update_joins_and_relates = True)

Lots of code right now surrounds these blocks, dumping out messages
and testing for layer types to be ignored... not showing any of that here.&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Sep 2023 18:04:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-properties-not-working/m-p/1326912#M68554</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2023-09-08T18:04:41Z</dc:date>
    </item>
  </channel>
</rss>

