<?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 ChangeVersion issue in Pro 3.2.1? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/changeversion-issue-in-pro-3-2-1/m-p/1549741#M12194</link>
    <description>&lt;P&gt;I am trying to construct a start/stop editing button that will also switch to the appropriate version for the user that is logged in to the database. I am having an issue changing versions from SDE.Default to a child version of a child (if that makes sense). We have versions that are children of default and then I build editable private child versions off of those. Am I missing a step somewhere?&amp;nbsp; The Contents pane does not refresh to indicate that version change occurs. It doesn't error out - it just doesn't do anything.Using the Change Version tool in Pro&amp;nbsp; works.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;using Version = ArcGIS.Core.Data.Version;
internal class StartStopEditing : Button
    {
        public Geodatabase transactionalGDB = null;
        protected async override void OnClick()
        {
            if (!Project.Current.IsEditingEnabled)
            {
                //Change or Create Version based on user name
                //Get the BOZAS layer from the map
                FeatureLayer pFL = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(x =&amp;gt; x.Name == "BOZAS") as FeatureLayer;
                if (pFL != null)
                {
                    //Get the BOZAS layer geodatabase and from that the user name
                    Datastore ds = await Helper.GetDatastoreFromFeatureLayer(pFL) as Datastore;
                    await QueuedTask.Run(() =&amp;gt;
                    {
                        if (ds.GetConnectionString().ToUpper().Contains(Helper.desktopConfig.Transactional.ToUpper()))
                        {
                            transactionalGDB = ds as Geodatabase;
                            Helper.g_User = (ds.GetConnector() as DatabaseConnectionProperties).User;
                        }
                    });


                    string versionName = "BOZAS_" + Helper.g_User.ToUpper();
                    if (transactionalGDB != null)
                    {
                        await QueuedTask.Run(() =&amp;gt;
                        {
                            using (VersionManager versionManager = transactionalGDB.GetVersionManager())
                            {
                                Version fromVersion = versionManager.GetCurrentVersion();
                                //Check if Version Exists
                                IReadOnlyList&amp;lt;string&amp;gt; versionList = versionManager.GetVersionNames();
                                if (versionList.Contains(Helper.g_User.ToUpper() + "." + versionName))
                                {
                                    //If So, Change to It
                                    Version userVersion = versionManager.GetVersion(Helper.g_User.ToUpper() + "." + versionName);
                                    MapView.Active.Map.ChangeVersion(fromVersion, userVersion);
                                }
                                //If not, create it and then switch to it
                                else
                                {
                                    VersionDescription versionDescription = new VersionDescription() { AccessType = VersionAccessType.Private, Name = versionName, Description = "BOZAS Edit Version: " + Helper.g_User };
                                    Version parent = versionManager.GetVersion("JEFLIB.JEFLIB_E"); //This is set to Public
                                    Version newVersion = versionManager.CreateVersion(versionDescription, parent);
                                   
                                    MapView.Active.Map.ChangeVersion(fromVersion, newVersion);
                                }
                            }
                        });
                        //Enable Editing
                        await Project.Current.SetIsEditingEnabledAsync(true);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("No BOZAS layer found. Please insure that the BOZAS.aprx file is open in ArcGISPro and that the BOZAS layer has not been removed or renamed.", "No BOZAS Layer", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
                    return;
                }
            }

            if (Project.Current.IsEditingEnabled)
            {
                //Deal with saving edits before setting SetIsEditingEnabledAsync to false
                Project.Current.SetIsEditingEnabledAsync(false);
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Oct 2024 21:41:24 GMT</pubDate>
    <dc:creator>ScottDickison1</dc:creator>
    <dc:date>2024-10-17T21:41:24Z</dc:date>
    <item>
      <title>ChangeVersion issue in Pro 3.2.1?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/changeversion-issue-in-pro-3-2-1/m-p/1549741#M12194</link>
      <description>&lt;P&gt;I am trying to construct a start/stop editing button that will also switch to the appropriate version for the user that is logged in to the database. I am having an issue changing versions from SDE.Default to a child version of a child (if that makes sense). We have versions that are children of default and then I build editable private child versions off of those. Am I missing a step somewhere?&amp;nbsp; The Contents pane does not refresh to indicate that version change occurs. It doesn't error out - it just doesn't do anything.Using the Change Version tool in Pro&amp;nbsp; works.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;using Version = ArcGIS.Core.Data.Version;
internal class StartStopEditing : Button
    {
        public Geodatabase transactionalGDB = null;
        protected async override void OnClick()
        {
            if (!Project.Current.IsEditingEnabled)
            {
                //Change or Create Version based on user name
                //Get the BOZAS layer from the map
                FeatureLayer pFL = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(x =&amp;gt; x.Name == "BOZAS") as FeatureLayer;
                if (pFL != null)
                {
                    //Get the BOZAS layer geodatabase and from that the user name
                    Datastore ds = await Helper.GetDatastoreFromFeatureLayer(pFL) as Datastore;
                    await QueuedTask.Run(() =&amp;gt;
                    {
                        if (ds.GetConnectionString().ToUpper().Contains(Helper.desktopConfig.Transactional.ToUpper()))
                        {
                            transactionalGDB = ds as Geodatabase;
                            Helper.g_User = (ds.GetConnector() as DatabaseConnectionProperties).User;
                        }
                    });


                    string versionName = "BOZAS_" + Helper.g_User.ToUpper();
                    if (transactionalGDB != null)
                    {
                        await QueuedTask.Run(() =&amp;gt;
                        {
                            using (VersionManager versionManager = transactionalGDB.GetVersionManager())
                            {
                                Version fromVersion = versionManager.GetCurrentVersion();
                                //Check if Version Exists
                                IReadOnlyList&amp;lt;string&amp;gt; versionList = versionManager.GetVersionNames();
                                if (versionList.Contains(Helper.g_User.ToUpper() + "." + versionName))
                                {
                                    //If So, Change to It
                                    Version userVersion = versionManager.GetVersion(Helper.g_User.ToUpper() + "." + versionName);
                                    MapView.Active.Map.ChangeVersion(fromVersion, userVersion);
                                }
                                //If not, create it and then switch to it
                                else
                                {
                                    VersionDescription versionDescription = new VersionDescription() { AccessType = VersionAccessType.Private, Name = versionName, Description = "BOZAS Edit Version: " + Helper.g_User };
                                    Version parent = versionManager.GetVersion("JEFLIB.JEFLIB_E"); //This is set to Public
                                    Version newVersion = versionManager.CreateVersion(versionDescription, parent);
                                   
                                    MapView.Active.Map.ChangeVersion(fromVersion, newVersion);
                                }
                            }
                        });
                        //Enable Editing
                        await Project.Current.SetIsEditingEnabledAsync(true);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("No BOZAS layer found. Please insure that the BOZAS.aprx file is open in ArcGISPro and that the BOZAS layer has not been removed or renamed.", "No BOZAS Layer", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
                    return;
                }
            }

            if (Project.Current.IsEditingEnabled)
            {
                //Deal with saving edits before setting SetIsEditingEnabledAsync to false
                Project.Current.SetIsEditingEnabledAsync(false);
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 21:41:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/changeversion-issue-in-pro-3-2-1/m-p/1549741#M12194</guid>
      <dc:creator>ScottDickison1</dc:creator>
      <dc:date>2024-10-17T21:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: ChangeVersion issue in Pro 3.2.1?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/changeversion-issue-in-pro-3-2-1/m-p/1595093#M12742</link>
      <description>&lt;P&gt;we have same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; Create new version&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; map.ChangeVersion(default, newver)&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; manually save projects. and exit ArcGIS Pro Application.&lt;/P&gt;&lt;P&gt;4.&amp;nbsp; Open saved Project.&lt;/P&gt;&lt;P&gt;5.&amp;nbsp; while( parent != null )&amp;nbsp; map.ChangeVersion( current, parent )&lt;/P&gt;&lt;P&gt;6.&amp;nbsp; Create new Version&lt;/P&gt;&lt;P&gt;7. map.ChangeVersion( default, newVer )&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; but&amp;nbsp; version does not change to newVer. still sde.DEFAULT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 10:26:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/changeversion-issue-in-pro-3-2-1/m-p/1595093#M12742</guid>
      <dc:creator>miyukioki</dc:creator>
      <dc:date>2025-03-13T10:26:25Z</dc:date>
    </item>
  </channel>
</rss>

