Select to view content in your preferred language

Problem using scripts to calculate fields in ArcPro Fabric Branched Versioning 3.0+

636
1
11-14-2022 05:13 AM
Labels (1)
DeanAnderson2
Frequent Contributor

We use a lot of tools/scripts to calculate values within the ArcPro/Parcel Fabric Branched Version Environment (when it makes sense not to use tasks or calc attribute rules).   I am testing Version 3.0+ and have run into the following problem and am hoping that I may doing something wrong.  After a lot of testing I have created the following simple script that that illustrates the problem. (This all works fine in 2.94 and in a standard GeoDatabase). We do not use SDE for editing. 

Start State: Within Branched Version (GISADMIN.T67_9c_Test200Anno4)  map session, Anno0200Scale feature class with Field (MapNumber) with value set to '6.3.8C').  

Process: APRX is open, Tool in Tool Box runs script,  Select OBJECTID = 7695 and Calc the value for MapNumber to be "XXXX" .  I have tested this using arcpy.da.Editor using UpdateCursor with the Source being: 

https://giscarts.co.polk.or.us/server/rest/services/PF/Parcel_Fabric_3/FeatureServer;VERSION=GISADMI...  which I calculate from the datasource of the Anno0200Scale feature class (after I removed the feature class name from the datasource text string).  

I have tested this without using the arcpy.da.Editor with da.UpdateCursor.  I have also tested this with a simple CalculateField both using the arcpy.da.editor and not using it.  

Problem:  I always get the same result.  NOTHING HAPPENS unless I close the ArcPro session and reopen it. Then I can see the change.  Using refresh screen / Change Version tool etc... None of it works.  Its like the edit did not happen until I close the session and then go back in.  My hope is that I am doing something wrong and somebody can help me out.  Below is the script (again this is not production just a test).  - it is also attached as a txt file.  Finally, within a simple edit session I can interactively select features and calculate attributes, see the results with no problem.  

import arcpy, os

# 1. Get parameter values

AnnoLayer = 'Anno0200Scale'

#2. Set Map Layers and default paths

thisProject = arcpy.mp.ArcGISProject("CURRENT")
Map = thisProject.activeMap
AnnoLyr = Map.listLayers(AnnoLayer)[0]
FolderPath = thisProject.homeFolder

arcpy.AddMessage ("Map: " + Map.name)
arcpy.AddMessage (AnnoLyr.dataSource)

datasource = AnnoLyr.dataSource
lastslash = datasource.rfind("/")
workspace = datasource[:lastslash]

arcpy.AddMessage(workspace)

MapNumber = 'XXXX'

# do edit session (Comment it out if you do not want to use it

edit = arcpy.da.Editor(workspace)
edit.startEditing(with_undo=False, multiuser_mode=True)
edit.startOperation()

with arcpy.da.UpdateCursor(AnnoLyr, ["MapNumber"],"OBJECTID = 7695") as cursor:
for row in cursor:
row[0] = MapNumber
cursor.updateRow(row)

edit.stopOperation()
edit.stopEditing(save_changes=True)

 

 

1 Reply
DeanAnderson2
Frequent Contributor

This problem may be larger then first reported.  I ran the following interactively.  I have a feature class (displayed as a layer) in a local geodatabase (Taxlot_linesAnno0200) and a branched version service layer called Anno0200Scale.  

DeanAnderson2_0-1668445425715.png

 

I attempted to append the features (4) in Taxlot_linesAnno2400 to a branched version Layer (Anno0200Scale).   

DeanAnderson2_1-1668445517363.png

 

When finished the 4 features do NOT appear in my Anno020)Scale feature class.  However the DO appear in the attribute table.  

DeanAnderson2_2-1668445640675.png

If I double click on the row in the table THEN it will appear on the map.  In addition if I leave the project and re-open the project then all features will appear normally.   I am hoping we have something setup incorrectly in how I am referencing this version or if it is a bug it gets fixed soon.  I will be reporting this as a bug today. 

 

 

 

 

0 Kudos