<?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: Copy operational layers object from one web map to another in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879848#M5059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks - that worked!&amp;nbsp; It seems like the definition attribute isn't listed in the documentation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I was able to get the operation to work by doing the following:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;srcData = srcMap.get_data()
destData = destMap.get_data()
destData['operationalLayers'] = srcData['operationalLayers']
destMap.update(data=str(destData))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 17:02:24 GMT</pubDate>
    <dc:creator>Jay_Gregory</dc:creator>
    <dc:date>2021-12-12T17:02:24Z</dc:date>
    <item>
      <title>Copy operational layers object from one web map to another</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879846#M5057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to use&amp;nbsp;ArcGIS Python API (v. 1.4.1) to copy the operational layers from one map to another in the same 10.6 Portal (for a development map / production map environment where I make changes to the development maps' symbology, layers, popups, etc., and then just copy the entire operational layers object to the production map), but I can't get it to work (even though it worked on a previous version of the API / previous version of Portal).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my old code, which worked in a previous version.&lt;/P&gt;&lt;P&gt;In this version, the code successfully runs, but the destination map isn't changed.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; Item
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping

portal &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fportalurl%2Fwebcontext" target="_blank"&gt;https://portalurl/webcontext&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"username"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"password"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; verify_cert&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
srcMap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Item&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;portal&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"5959197ba01748ccb51cf097597b4cf4"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
destMap&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Item&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;portal&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"e326e343d5aa45668a448e54acc4d06d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
opsLayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; srcMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get_data&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'operationalLayers'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
mapDestObj &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;WebMap&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;destMap&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
mapDestObj&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'operationalLayers'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; opsLayers
mapDestObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;update&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&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;P&gt;&lt;/P&gt;&lt;P&gt;I've also followed instructions located at&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/python/sample-notebooks/using-and-updating-gis-content/" title="https://developers.arcgis.com/python/sample-notebooks/using-and-updating-gis-content/" rel="nofollow noopener noreferrer" target="_blank"&gt;Using and updating GIS content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;, but that doesn't seem to work either.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mapDestObj has a layers attribute, but mapDestObj.layers = opsLayers throws an AttributeError (can't set attribute)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried the following: which successfully updates the mapDestObj.layers attribute, but doesn't save the map when I run the update command.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; index&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; layer &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; enumerate&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mapDestObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDestObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; opsLayers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
webMapObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;update&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have a working prototype for this workflow?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 11:05:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879846#M5057</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2021-12-12T11:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Copy operational layers object from one web map to another</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879847#M5058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" data-userid="26804" data-username="jay.gregory" href="https://community.esri.com/people/jay.gregory" style="color: #3778c7; background-color: #ffffff; border: 0px; font-weight: 600; text-decoration: underline; font-size: 13.7136px;" target="_blank"&gt;Jay Gregory&lt;/A&gt;,&lt;SPAN style="color: #8b8b8b; background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;i&lt;/SPAN&gt;&lt;/SPAN&gt;n your&amp;nbsp;first snippet, you may have to change the last but one line to the following&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# your current line&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# mapDestObj['operationalLayers'] = opsLayers‍&lt;/SPAN&gt;
mapDestObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;definition&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'operationalLayers'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; opsLayers‍
mapDestObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;update&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and that should work. Can you give this a try and let me know?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 11:05:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879847#M5058</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T11:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Copy operational layers object from one web map to another</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879848#M5059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks - that worked!&amp;nbsp; It seems like the definition attribute isn't listed in the documentation.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I was able to get the operation to work by doing the following:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;srcData = srcMap.get_data()
destData = destMap.get_data()
destData['operationalLayers'] = srcData['operationalLayers']
destMap.update(data=str(destData))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 17:02:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879848#M5059</guid>
      <dc:creator>Jay_Gregory</dc:creator>
      <dc:date>2021-12-12T17:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Copy operational layers object from one web map to another</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879849#M5060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are welcome. For future reference, the correct way to do your workaround is to pass a dictionary with key= "text" and value = your web map dict. So the last line should look like this&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; json
destMap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;update&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;data&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'text'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;json&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dumps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;destData&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 11:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/copy-operational-layers-object-from-one-web-map-to/m-p/879849#M5060</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T11:05:26Z</dc:date>
    </item>
  </channel>
</rss>

