<?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: Is there something wrong with lyr.replaceDataSource ? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217084#M16724</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the suggestions, now that I know how to insert code I'll show what I've tested out. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;first of all using the {False} parameter has shown some progress!&amp;nbsp; the code works....sort of.&amp;nbsp; So far it is changing the folder location, the FGDB name, and the feature class name but&amp;nbsp;&lt;EM&gt;not&lt;/EM&gt; &lt;EM&gt;the feature dataset name&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;here is the test code:&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; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;supports&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"DATASOURCE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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 class="keyword token"&gt;if&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"L:\Data\CFX_2016_160214\GDB\CFX_2016.gdb\CFX_IFS_Working_16\AA_Points"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replaceDataSource&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb\IFS_Working"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FILEGDB_WORKSPACE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BB_Points"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BB_Points"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource
&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;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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and this is the output:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb\CFX_IFS_Working_16\BB_Points‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Is this something that the lyr.replaceDataSource() can't do?&lt;/P&gt;&lt;P&gt;if I use the {True} parameter, I don't get past line 4 and I think that is due to the fact that I have included the dataset name in the path.&amp;nbsp; How do I navigate into feature datasets?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:37:05 GMT</pubDate>
    <dc:creator>AnnaBuchheit</dc:creator>
    <dc:date>2021-12-11T10:37:05Z</dc:date>
    <item>
      <title>Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217075#M16715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been racking my brain trying to figure out why I can't get this simple code to execute properly.&amp;nbsp; I am trying to replace Datasources for numerous layers in numerous mxd's.&amp;nbsp; I&amp;nbsp;&lt;EM&gt;really&lt;/EM&gt; don't want to do this manually!&amp;nbsp; Essentially, a new file gdb has been created in a new folder with renamed feature classes.&amp;nbsp; Feature class names were changed to simplify other geoprocessing scripts. Now I need to re-link the datasources to the new datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have a working code:&amp;nbsp; it walks through a directory, it lists mxd's by file name, it finds layers and prints their names and finally saves the mxd.&amp;nbsp; there are no bugs; however, when I open the mxd, the datasource has not changed.&amp;nbsp; The script runs through the lyr.replaceDataSource but does not actually replace the datasource.&amp;nbsp; I have used the validate {FALSE} parameter and still no luck!&amp;nbsp; I am not a whiz when it comes to python, but I thought this was a pretty straight forward script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone see what I am doing wrong?&amp;nbsp; What am I overlooking?&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/398661_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/confused.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2018 20:47:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217075#M16715</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-12T20:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217076#M16716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do you have a&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mxd.save()&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: line-through;"&gt;anywhere in your script?&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Edit:&amp;nbsp; never mind...just saw it.&amp;nbsp; &amp;nbsp; But I thik it needs to be indented.&amp;nbsp; Looks like you would only be saving the last mxd changed.&amp;nbsp; But haven't looked closely at your code (short on time).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an addin if you are interested in using, or just reviewing the code.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/myAlaskaGIS/2015/08/31/python-addin-for-data-inventory-and-broken-link-repair?sr=search&amp;amp;searchId=3771fb19-dc97-4e17-b98f-adf107ab692b&amp;amp;searchIndex=2"&gt;/blogs/myAlaskaGIS/2015/08/31/python-addin-for-data-inventory-and-broken-link-repair?sr=search&amp;amp;searchId=3771fb19-dc97-4e17-b98f-adf107ab692b&amp;amp;searchIndex=2&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Mar 2018 21:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217076#M16716</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2018-03-12T21:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217077#M16717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested the code using only one mxd and still nothing changes.&amp;nbsp; I'm stumped!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2018 18:51:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217077#M16717</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-13T18:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217078#M16718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you might need a mxd.SaveACopy and then use file manipulation to rename the newly created mxd to the original mxd name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2018 18:58:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217078#M16718</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-03-13T18:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217079#M16719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anna&lt;/P&gt;&lt;P&gt;From the help....&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatingandfixingdatasources.htm"&gt;http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/updatingandfixingdatasources.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This seems to be used... worth a whirl&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;mxd&lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;saveACopy&lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #a31515; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;r"C:\Project\Project2.mxd"&lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: transparent; color: #0000ff; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;del&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #fafafa; color: #4d4d4d; font-family: 'Consolas','Andale Mono','Lucida Console','Monaco','Courier New',Courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px; word-wrap: normal;"&gt; &lt;/SPAN&gt;&lt;SPAN style="background-color: transparent; color: #4d4d4d; font-family: &amp;amp;quot; consolas&amp;amp;quot;,&amp;amp;quot;andale mono&amp;amp;quot;,&amp;amp;quot;lucida console&amp;amp;quot;,&amp;amp;quot;monaco&amp;amp;quot;,&amp;amp;quot;courier new&amp;amp;quot;,courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;mxd&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #fafafa; color: #4d4d4d; font-family: 'Consolas','Andale Mono','Lucida Console','Monaco','Courier New',Courier,monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px; word-wrap: normal;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the future, actual pop the code in using syntax highlighting instead of an image, it might help if people want to actually&lt;/P&gt;&lt;P&gt;try it without retyping&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;Code Formatting... the Basics ++&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:01:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217079#M16719</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-03-13T19:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217080#M16720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the tip Re: inserting code... this is my first post &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 00:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217080#M16720</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-14T00:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217081#M16721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, I'll give it a try &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 00:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217081#M16721</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-14T00:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217082#M16722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wondering about line 12 in your script:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;List&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Should it be (ListLayers):&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 02:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217082#M16722</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-03-14T02:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217083#M16723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have multiple dataframes in your mxd, you will need to loop through them as well, as I believe the current code will only resource layers in the active dataframe.&amp;nbsp; Not sure this applies to you, but something to consider.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:38:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217083#M16723</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2018-03-14T13:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217084#M16724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the suggestions, now that I know how to insert code I'll show what I've tested out. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;first of all using the {False} parameter has shown some progress!&amp;nbsp; the code works....sort of.&amp;nbsp; So far it is changing the folder location, the FGDB name, and the feature class name but&amp;nbsp;&lt;EM&gt;not&lt;/EM&gt; &lt;EM&gt;the feature dataset name&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;here is the test code:&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; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;supports&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"DATASOURCE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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 class="keyword token"&gt;if&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"L:\Data\CFX_2016_160214\GDB\CFX_2016.gdb\CFX_IFS_Working_16\AA_Points"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replaceDataSource&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb\IFS_Working"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FILEGDB_WORKSPACE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BB_Points"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&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;&amp;nbsp;&amp;nbsp; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BB_Points"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataSource
&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;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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and this is the output:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb\CFX_IFS_Working_16\BB_Points‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Is this something that the lyr.replaceDataSource() can't do?&lt;/P&gt;&lt;P&gt;if I use the {True} parameter, I don't get past line 4 and I think that is due to the fact that I have included the dataset name in the path.&amp;nbsp; How do I navigate into feature datasets?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217084#M16724</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2021-12-11T10:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217085#M16725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;no I only have one dataframe, but I do have multiple Feature Datasets&lt;/P&gt;&lt;P&gt;...I have added to my thread below...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2018 21:03:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217085#M16725</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-15T21:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217086#M16726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With version 10.5, I was having some luck using something like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replaceDataSource&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FILEGDB_WORKSPACE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"BB_Points"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# omitting 'IFS_Working' from the path&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# L:\Data\CFX_2018_180214\gdb\CFX_2018.gdb\IFS_Working\BB_Points‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;It seems strange that the feature class name would be omitted from the path or layer name.&amp;nbsp; This could cause problem if other feature classes&amp;nbsp; in the file geodatabase contain an identical feature name.&amp;nbsp; Could it be a bug?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replacing the data source did not change the layer name, so that had to be set.&amp;nbsp; Also, the old symbology was retained, so that may also need to be corrected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I was working inside ArcMap's Python window and would use arcpy.RefreshActiveView to update the map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217086#M16726</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T10:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there something wrong with lyr.replaceDataSource ?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217087#M16727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used your suggestions for removing the "IFS_Working" from the path, as well as adding "NONE" as the workspace (as it does not change).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the code automatically sources it to the correct dataset!&amp;nbsp;&lt;/P&gt;&lt;P&gt;most of my trouble came from thinking too much (haha!), and mapping the path too far.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to everyone for the guidance &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/grin.png" /&gt;&amp;nbsp; I am but a&amp;nbsp;greenhorn teaching myself...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2018 20:22:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-something-wrong-with-lyr/m-p/217087#M16727</guid>
      <dc:creator>AnnaBuchheit</dc:creator>
      <dc:date>2018-03-16T20:22:51Z</dc:date>
    </item>
  </channel>
</rss>

