Problems with Arcp3.2 Parcel Fabric Using ArcPy to Change the Version

530
5
11-20-2023 05:14 AM
DeanAnderson2
Occasional Contributor II

I am using ArcPro 3.2 accessing 11.1 Enterprise (will be upgraded soon to 11.2). I am testing my 3.1x code for creating a version in 3.2. I based my code on the ESRI Post (Part 2 - Branch Version with Parcel Fabric).  This code has been working Great in 2.9 thru 3.1x.  In 3.2 I can no longer change the version of the "Records" Feature class directly. However, this appears to happen when I change the version of the ParcelFabric that the Records feature class is a member  of.  Unfortunately, when I do this I can no longer create a new record in the new version. My steps for this test. 

1. Create a new version (works great - no problem)
2. Get properties of new version (works great no problem)
3. Change the version manually (problems - Dialogue box is blank but code runs fine and version changes but problems) 

Code is as follows for changing the version is as follows:

Versionmap = thisProject.listMaps("Map")[0]           # Map map in my project (thisProject) 
pfLayer = Versionmap.listLayers("TaxlotsPF")[0]       #TaxlotPF is my parcel fabric 
arcpy.AddMessage("-lyr: " + str(pfLayer.name))        # Just a message 
updated_props = pfLayer.connectionProperties

arcpy.AddMessage(updated_props)                          # message to check properties 
arcpy.AddMessage('-----------------------')
updated_props["connection_info"]["version"] = new_version_fullname          # Props of the new version 
updated_props["connection_info"]["versionguid"] = new_version_guid
pfLayer.updateConnectionProperties(pfLayer.connectionProperties,updated_props,auto_update_joins_and_relates = True, validate=True)
new_props = pfLayer.connectionProperties

Please let me know if I am doing something wrong ? I have tried several variations of this tool and also tried to use the changeversion tool.  None seem to work.  

5 Replies
DeanAnderson2
Occasional Contributor II

As a follow up.  When I use the ChangeVersion tool in the python script as follows, all of the feature classes that participate in the record change.  Unfortunately, the "TaxlotsPF: Records" feature class does not and remains in the old version. 

Versionmap = thisProject.listMaps("Map")[0]              # same map as before 
pfLayer = Versionmap.listLayers("TaxlotsPF")[0]         # same fabric as before 

edit = arcpy.da.Editor(WorkSpace)                           # my workspace 
edit.startEditing(False, False)
edit.startOperation()

arcpy.management.ChangeVersion(
    in_features=pfLayer,
    version_type="BRANCH",
    version_name=new_version_fullname,
    date=None,
    include_participating="INCLUDE"
)

edit.stopOperation()
edit.stopEditing(True)

The results are.... All feature classes Except Records are transferred to the new eversion (also no error message). 

DeanAnderson2_0-1700488365208.png

 

 

KenGalliher1
Esri Contributor

Hi Dean,

Thanks for bringing this up. I am getting mixed results with different methods.

I am not able to reproduce the issue using Pro 3.2 or Pro 3.1.4 from the Python Window with an open map (target_map("CURRENT")) or from a script pointing to the map project.

Interestingly, I can reproduce it with a Notebook using an open map (target_map("CURRENT")).

To make sure we're on the same page, with the sample code above, are you expecting only the parcel fabric to switch to the version? I believe we determined that we had to iterate through all of the feature layers to change their version.

This is my map after targeting only the parcel fabric:

KenGalliher1_0-1700505404020.png

 

UPDATE:

I ran the script from the Python window and the parcel fabric and parcel layers all change version. The topology does not:

KenGalliher1_0-1700506918222.png

 

 

0 Kudos
DeanAnderson2
Occasional Contributor II

Thanks for getting back to me.  I am able to iterate thru all the layers.  In interating through the list the script I USED to be able to include "Records" (FC/Layer) in the layer list.  It now errors out saying that you can no longer do this.  Best error message I get is when I use the "Change Version" tool on the "Records" layer.  This also errors out in 3.2 (not 3.1X) python scripts.  The problem comes when I try to use the python script to use the updateConnectionProperties method on the fabric (TaxlotsPF).  When I use this the record is not accessible and if I try to create new record in this new version (because the fabric appears to have been moved) I ONLY see a "blank" menu (no prompts) or anything.  I have attached the text script I used. Hope it helps.  

Again...  The script allows me to change the feature classes / layers  associated with the fabric (LOTS,PLATS,TAXLOTS,etc) and that all works fine.  Changing other (non-fabric)  feature classes (to the version) also works fine.  The only layer that does not work correctly is the Records layers that is directly associated with the fabric . 

DeanAnderson2_0-1700509970371.png

 

0 Kudos
Ofir_Mazor
New Contributor II

I'm encountering the same issue with transferring layers using the gp tool "Change version" or the arcpy.management.ChangeVersion function. When I utilize them within the Python window in ArcGIS Pro, all layers along with the Records moves to the new version seamlessly. However, when I execute arcpy.management.ChangeVersion from a script ouside ArcGIS Pro, all layers except the Records are moved, and no error message is displayed.

I'm using ArcGIS version 3.1.1. Here's my arcpy code:

 

 

from configs import CNFG
import getpass
from arcpy.management import CreateVersion, ChangeVersion


def open_version(ProcessName:str):
    '''Creates a new version in a geodatabase.'''
    
    user = getpass.getuser()
    version_name = generate_version_name(ProcessName)
    CreateVersion(in_workspace = CNFG.FeatureServer, parent_version = "sde.DEFAULT", version_name = version_name, access_permission = 'PUBLIC')
    
    records_layer = arcpy.mp.ArcGISProject("CURRENT").listMaps()[0].listLayers('Records')[0]
    topology_layer = arcpy.mp.ArcGISProject("CURRENT").listMaps()[0].listLayers('Topology')[0]
    
    for layer in [records_layer, topology_layer]: 
        if layer is None:
            AddMessage(f'{layer} was not found')
               
    ChangeVersion(in_features = records_layer, version_type = "BRANCH", version_name = f"{user}@MM_NT_MALI.{version_name}", date=None, include_participating = "INCLUDE")
    ChangeVersion(in_features = topology_layer, version_type = "BRANCH", version_name = f"{user}@MM_NT_MALI.{version_name}", date=None, include_participating = "INCLUDE")
    
    AddMessage(f'New version {version_name} created successfully')

 

 

 

 

versions.png

0 Kudos
KenGalliher1
Esri Contributor

Hi Ofir,

This is a known issue with the Change Version GP tool and we are working on fixing it in an upcoming release.  This will help change the version for all container datasets and their associated layers (Parcel Fabric, Utility Network, etc.). In the meantime, we have found success using the ArcGIS Python API to access version information and loop through each layer in the map to change its properties.

See this post specifically

 

Thanks,

Ken

 

 

 

 

0 Kudos