<?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: Opening a dataset prevents version from being deleted in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/opening-a-dataset-prevents-version-from-being/m-p/1128124#M63303</link>
    <description>&lt;P&gt;Hello JonathanBailey,&lt;/P&gt;&lt;P&gt;How is this issue going? I was able to run this code successfully with a mock block layer and detail table without the error message.&lt;/P&gt;&lt;P&gt;If you're still having the issue, you could try the arcpy.DisconnectUser() function to disconnect any users accessing the version. Link: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/disconnectuser.htm" target="_self"&gt;DisconnectUser&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
    <pubDate>Tue, 21 Dec 2021 19:12:12 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-21T19:12:12Z</dc:date>
    <item>
      <title>Opening a dataset prevents version from being deleted</title>
      <link>https://community.esri.com/t5/python-questions/opening-a-dataset-prevents-version-from-being/m-p/1124070#M63183</link>
      <description>&lt;P&gt;I've created a Python script that creates a version, opens datasets on it, then attempts to delete the version. If the ArcPy workspace environment variable is set to a workspace pointing to the created version, and if a dataset is opened, it seems impossible to delete the version.&lt;/P&gt;&lt;P&gt;Following is Python code to reproduce:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

workspace = "&amp;lt;path to .sde file connecting to sde.DEFAULT version&amp;gt;"
edit_version_workspace = "&amp;lt;path to .sde file connecting to sde.DEFAULT version&amp;gt;"
BLOCKS_FEATURE_CLASS = "&amp;lt;block layer&amp;gt;"
DETAIL_TABLE = "&amp;lt;detail table&amp;gt;"

arcpy.management.CreateVersion(workspace, "sde.DEFAULT", "TestVersion", "PROTECTED")
arcpy.env.workspace = edit_version_workspace

blocks_joined_to_details = arcpy.management.AddJoin(BLOCKS_FEATURE_CLASS, "OBJECTID", DETAIL_TABLE, "BLOCKOID", "KEEP_ALL")
del blocks_joined_to_details

arcpy.env.workspace = workspace
arcpy.ClearWorkspaceCache_management(edit_version_workspace)
arcpy.DeleteVersion_management(workspace, "&amp;lt;user&amp;gt;.TestVersion")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When calling the DeleteVersion_management function, an error is returned:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;ERROR 160363: The version is currently in use.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Failed to execute (DeleteVersion).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Commenting out the lines to create the joined dataset and delete it prevent this error from occurring and the version is successfully deleted.&lt;/P&gt;&lt;P&gt;How do I get rid of the reference to the version that's preventing me from deleting it?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 23:18:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/opening-a-dataset-prevents-version-from-being/m-p/1124070#M63183</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-08T23:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Opening a dataset prevents version from being deleted</title>
      <link>https://community.esri.com/t5/python-questions/opening-a-dataset-prevents-version-from-being/m-p/1128124#M63303</link>
      <description>&lt;P&gt;Hello JonathanBailey,&lt;/P&gt;&lt;P&gt;How is this issue going? I was able to run this code successfully with a mock block layer and detail table without the error message.&lt;/P&gt;&lt;P&gt;If you're still having the issue, you could try the arcpy.DisconnectUser() function to disconnect any users accessing the version. Link: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/disconnectuser.htm" target="_self"&gt;DisconnectUser&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 19:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/opening-a-dataset-prevents-version-from-being/m-p/1128124#M63303</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-21T19:12:12Z</dc:date>
    </item>
  </channel>
</rss>

