<?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>idea Allow Python to edit on versions in branch versioned datasets in Data Management Ideas</title>
    <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idi-p/1651545</link>
    <description>&lt;P&gt;This has to be an idea already and I just can't find it. I would like to be able to use Python to edit a version on branch versioned data sets. Right now, the only way I can see to script out batch editing is to write the edits to DEFAULT. That causes database bloat that could be reduced by editing on a version and then post/reconciling programmatically.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Sep 2025 17:00:47 GMT</pubDate>
    <dc:creator>AmyRoust</dc:creator>
    <dc:date>2025-09-18T17:00:47Z</dc:date>
    <item>
      <title>Allow Python to edit on versions in branch versioned datasets</title>
      <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idi-p/1651545</link>
      <description>&lt;P&gt;This has to be an idea already and I just can't find it. I would like to be able to use Python to edit a version on branch versioned data sets. Right now, the only way I can see to script out batch editing is to write the edits to DEFAULT. That causes database bloat that could be reduced by editing on a version and then post/reconciling programmatically.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 17:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idi-p/1651545</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-09-18T17:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Allow Python to edit on versions in branch versioned datasets</title>
      <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651611#M2565</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/82823"&gt;@AmyRoust&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To edit &lt;STRONG&gt;ArcGIS Enterprise branch version feature services via Python&lt;/STRONG&gt;, you typically use the &lt;STRONG&gt;ArcGIS API for Python&lt;/STRONG&gt;, which provides tools to interact with services hosted on ArcGIS Enterprise, including versioned feature services.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/working-with-branch-versioning/" target="_blank" rel="noopener"&gt;Working with Branch Versioning | ArcGIS API for Python&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

# Connect to your portal
gis = GIS("https://your-portal-url.com/portal", "username", "password")

# Access the feature service
flc = FeatureLayerCollection("https://your-portal-url.com/arcgis/rest/services/YourService/FeatureServer", gis)

# Create or switch to a branch version
version_name = "Marcelo_Edit_Version"
version = flc.manager.create_version(version_name, description="Editing version for updates")

# Access the specific layer
layer = flc.layers[0] # assuming you want the first layer

# Set the version context
layer.version = version_name

# Query features to edit
features = layer.query(where="OBJECTID = 1", out_fields="*", return_geometry=True).features

# Modify attributes or geometry
features[0].attributes["Status"] = "Updated"

# Apply edits
layer.edit_features(updates=features)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Sep 2025 19:28:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651611#M2565</guid>
      <dc:creator>MarceloMarques</dc:creator>
      <dc:date>2025-09-18T19:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Allow Python to edit on versions in branch versioned datasets - Status changed to: Already Offered</title>
      <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651657#M2566</link>
      <description>&lt;P&gt;There are multiple ways to edit a branch versioned dataset.&amp;nbsp; All editing of branch versioned data must happen through its feature service.&amp;nbsp; Publishing the data as a by reference service and then using either the ArcGIS API for python as&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7880"&gt;@MarceloMarques&lt;/a&gt;&amp;nbsp;has suggested, or arcpy are both acceptable.&amp;nbsp; Below is an example of how you would edit using arcpy instead of the ArcGIS API for Python.&lt;BR /&gt;&lt;BR /&gt;Since there are multiple ways to achieve the requested functionality, I will close this as already offered.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# User will need to sign in using their preferred method

import arcpy

server = &amp;lt;&amp;lt; your branch versioned feature server url &amp;gt;
version_name = 'new_version_aa'

# Create a new version using the feature server
arcpy.management.CreateVersion(server, 'sde.DEFAULT', version_name)

# Create a Feature Layer
# Just assuming its the 0 indexed layer here for ease of example
new_lyr = arcpy.management.MakeFeatureLayer(f'{server}/0', 'test_lyr')

# Get the full version name
# Quick way to grab the newly created version name since it may contain more
# data, like the username, than was passed to CreateVersion GP tool
full_version_name = [v.name for v in arcpy.da.ListVersions(server) if version_name in v.name][0]

# Switch to the new version
arcpy.management.ChangeVersion(new_lyr, 'BRANCH', full_version_name)

# Edit the layer with a da.InsertCursor
with arcpy.da.InsertCursor(new_lyr, ['Field']) as cursor:
    cursor.insertRow([1000])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 16:55:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651657#M2566</guid>
      <dc:creator>SSWoodward</dc:creator>
      <dc:date>2025-09-19T16:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Allow Python to edit on versions in branch versioned datasets</title>
      <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651756#M2567</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/604859"&gt;@SSWoodward&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7880"&gt;@MarceloMarques&lt;/a&gt;&amp;nbsp;- Thank you! I have only dabbled in the ArcGIS API for Python and it didn't even occur to me to look there. I will pursue this path.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 13:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1651756#M2567</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-09-19T13:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Allow Python to edit on versions in branch versioned datasets</title>
      <link>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1665234#M2589</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/604859"&gt;@SSWoodward&lt;/a&gt;&amp;nbsp;I decided to go with your sample code since I'm already working with arcpy in a file on my server. I successfully created the new version:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;server = f"https://xyz/FeatureServer"
version_name = 'python'
arcpy.management.CreateVersion(server, 'sde.DEFAULT', version_name)
new_lyr = arcpy.management.MakeTableView(f'{server}/15', 'default_lyr')
full_version_name = [v.name for v in arcpy.da.ListVersions(server) if version_name in v.name][0]
meter = arcpy.management.ChangeVersion(new_lyr, 'BRANCH', full_version_name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;But I cannot get it to switch back to DEFAULT before posting and reconciling.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.ChangeVersion(new_lyr, 'BRANCH', 'sde.DEFAULT')
arcpy.management.ReconcileVersions(server, "ALL_VERSIONS", "sde.DEFAULT", full_version_name, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "DELETE_VERSION", r"C:\Log.txt", "PROCEED", "RECONCILE")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When line 2 runs, it says&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;"Warning: Error deleting version &lt;A href="mailto:xyz@LAWRENCEKS.ORG.python" target="_blank"&gt;xyz.python&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The version is currently in use. [xyz.python]&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;Not running inside a server process.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;SPAN&gt;I could change the reconcile to keep the version, but I'd prefer to delete it.&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Nov 2025 19:15:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-ideas/allow-python-to-edit-on-versions-in-branch/idc-p/1665234#M2589</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2025-11-12T19:15:23Z</dc:date>
    </item>
  </channel>
</rss>

