<?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: arcpy.ChangeVersion_management in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780143#M1162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you just typed the feature layer name in manually in the script.&amp;nbsp; Did you try passing the layer by reference, not by text, to the script tool and have the geoprocessing tool use that layer reference?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Dec 2018 14:56:22 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2018-12-03T14:56:22Z</dc:date>
    <item>
      <title>arcpy.ChangeVersion_management</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780141#M1160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quick question:&lt;/P&gt;&lt;P&gt;When I execute the lines in the python script below from the Python console within ArcGIS Pro (2.1) I am getting the expected result (the current layer is "changed" to the Version). Please refer to the screenshot&amp;nbsp;ChangeVersion_management.jpg where two database connections (one of them being the SDE.DEFAULT and the other one the versioned one containing the changed layer) are shown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT when I try to do the same by executing the script "as a tool" nothing seems to happen and the layer is NOT "changed" to the Version &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;def getcurrentuser():&lt;BR /&gt; username = os.environ.get("USERNAME")&lt;BR /&gt; username = username.upper()&lt;BR /&gt; return username&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set local variables&lt;BR /&gt;arcpy.env.workspace = r"C:\geodat1p.sde"&lt;BR /&gt;parentVersion = "SDE.DEFAULT"&lt;BR /&gt;versionName = sys.argv[1]&lt;BR /&gt;fullversionName = 'OPS$'+getcurrentuser()+'.'+versionName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Execute CreateVersion&lt;BR /&gt;arcpy.CreateVersion_management(arcpy.env.workspace, parentVersion, versionName, "PUBLIC")&lt;BR /&gt;arcpy.AddMessage("Version: {0} created".format(fullversionName))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Changes version on JackupSpud (the layer has already been added to the Map Content-menu/pane)&lt;BR /&gt;arcpy.ChangeVersion_management("Jack-up Spud",'TRANSACTIONAL', fullversionName,'')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What part of the picture am I not seeing?&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Do I need to create a new database connection referencing the Version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried to find a workaround by using the standard Change Version geoprocessing tool but running this on the particular layer referencing the new Version unfortunately doesn't seem to affect it either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking that perhaps the "List by Data Sources" wasn't automaticly getting updated when executing the function from "outside" the environment but it doesn't help to switch back and forth between the tabs and when I afterwards append data into the layer it unfortunately ends up directly in the SDE.DEFAULT-connection and not in my version-connection where I would like it to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2018 09:44:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780141#M1160</guid>
      <dc:creator>MartinHolleufer-Sørensen</dc:creator>
      <dc:date>2018-10-23T09:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ChangeVersion_management</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780142#M1161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This problem has now been registered as a bug:&amp;nbsp;&lt;A class="link-titled" href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDExNDAxNw==" title="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDExNDAxNw=="&gt;BUG-000114017: When calling the arcpy tool Change Version from a cu..&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2018 07:46:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780142#M1161</guid>
      <dc:creator>MartinHolleufer-Sørensen</dc:creator>
      <dc:date>2018-12-03T07:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ChangeVersion_management</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780143#M1162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you just typed the feature layer name in manually in the script.&amp;nbsp; Did you try passing the layer by reference, not by text, to the script tool and have the geoprocessing tool use that layer reference?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2018 14:56:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780143#M1162</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-12-03T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ChangeVersion_management</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780144#M1163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot for suggesting this, Joshua. Using the following lines in my script make the things work as I want them to (data appended to my SDE-version and not directly to SDE.DEFAULT) &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;arcpy.management.MakeFeatureLayer("c:\test.sde\JackupSpud", "JackupSpud")&lt;BR /&gt;arcpy.ChangeVersion_management("JackupSpud",'TRANSACTIONAL', fullversionName,'')&lt;/P&gt;&lt;P&gt;arcpy.Append_management(r"%scratchGDB%\NewJackupSpuds", 'JackupSpud', "TEST")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2018 12:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-changeversion-management/m-p/780144#M1163</guid>
      <dc:creator>MartinHolleufer-Sørensen</dc:creator>
      <dc:date>2018-12-14T12:53:24Z</dc:date>
    </item>
  </channel>
</rss>

