Select to view content in your preferred language

Branch Version Change To Default option in ArcGIS Pro 3.0 & Arcpy

08-19-2022 10:23 AM
New Contributor III

Hi All, 

As per our project requirement we want to build a tool using arcpy to change branch version to default.

Detailed Requirement

We are using BRANCH versioned feature service to perform editing's in ArcGIS Pro 3.0.

After completing the edits, requirement is to change the added feature service in TOC from 'child version' to 'SDE.DEFAULT' version using arcpy

Python code we are trying to use:

import arcpy

aprx ="C:\abc_Pro\Project\abc_Aprx.aprx")

m = aprx.listMaps('Map')[0]

for lyr in m.listLayers():
if ( == "APPROVED"):, "BRANCH", "sde.DEFAULT", None, "INCLUDE")

When we run the above script in "Python Notebook" in ArcGIS Pro, it is working fine.

When we run the same from python script (ex:, script executing with out errors but services are not changing to "DEFAULT" version.

Anything we are missing in this. Appreciate help on this. Thanks.

0 Kudos
1 Reply
Esri Regular Contributor

This area is for the Python API rather than ArcPy, but will try to address your question. I would start by adding some debugging information to your script, and checking what `m.listLayers()` shows when running in standalone Python. It is possible that the aprx hasn't been saved at the point in execution?  If the aprx exposes the right information, it may be that the GDB model is different in this case, but that seems less likely. 

Cheers, Shaun

0 Kudos