Hi All,
I'm new to versioned workflows and SDE environments. I'm trying to download hosted data, manipulate it, and append it to an SDE feature class that eventually syncs to another SDE. I've scripted the processes with python and tried it in model builder. The processes work, but the new data won't sync to the replica. If tried in a version, the scripted edits don't post. If I manually edit the feature classes, the edits move from version to default when posted and child to parent when synced. How do I get scripted changes to be recognized as changes?
Any help would be appreciated,
Tosh
I have this same issue right now.
I'm thinking we need to add this to the scripts. I'm going to give it a shot now...
https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/editor.htm
I hope it works for you. I tried that route with no luck.
It worked for me using Checkout Replica to File Geodatabase with the addition of the Editor class into the code.
"""
Spyder Editor
Richard Fairhurst is the MAN!
Many thanks to Richard Fairhurst for saving the GIS community countless hours of time!
Transfer of Multiple Field Values between Feature Classes where there is a 1:1
Match between Field Sets
Just like the Field Calculator the more fields being transferred from
one feature class to the other, the more your script will speed up.
If the transfer is a simple field for field transfer then the
transfer fields can be handled in a for loop. Below is an example
of a transfer of 5 matching fields between two feature classes.
To adapt this code to your data you should again change the feature classes
in lines 7 and 14 and the field lists in lines 9 and 16.
"""
from time import strftime
print( "Start script: " + strftime("%Y-%m-%d %H:%M:%S"))
import arcpy
sourceFC = r"G:\Mapping\Property\data\0SBFImports\SBFStaging20230731test.gdb\NewSBF_Candidate"
sourceFieldsList = ['PARCELID','ActiveRecord', 'Agency_Class_Number','Etc', 'Etc']
# Use list comprehension to build a dictionary from a da SearchCursor
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}
updateFC = r"G:\Mapping\Property\data\replicas\devProperty_replica1.gdb\AssessorSBF"
updateFieldsList = ['PARCELID','ACTIVERECORD', 'Agency_Class_Number','Etc', 'Etc']
workspace = r"G:\Mapping\Property\data\replicas\replicaPropertyTesting.gdb"
with arcpy.da.Editor(workspace) as edit:
with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:
for updateRow in updateRows:
# store the Join value of the row being updated in a keyValue variable
keyValue = updateRow[0]
# verify that the keyValue is in the Dictionary
if keyValue in valueDict:
# transfer the values stored under the keyValue from the dictionary to the updated fields.
for n in range (1,len(sourceFieldsList)):
updateRow[n] = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
print( "Finished script: " + strftime("%Y-%m-%d %H:%M:%S"))