Two editor tracking problems in ArcGIS Online and/or Collector
The edit tracking tools seem to have changed. (We used “Enable editing”, “Keep track of created and updated features”, “Keep track of who created and last updated features”, and “enable Sync”). Here are the issues:
The situation
I had a problem with retaining edit tracking for hosted feature services upon republishing. I use an XML Geodatabase modeling tool (Sparx EA) to make geodatabse model updates, and python to stage the data, actually a jupyter notebook.
first I do something like this:
#add edit tracking to all the feature classes AND DISABLE EDIT TRACKING
from arcpy import ListFeatureClasses, ListDatasets, EnableEditorTracking_management, DisableEditorTracking_management, env
#NewDatabase = r'c:\temp\CollectorGDB_2018081502.gdb'
env.workspace = NewDatabase
print (env.workspace)
datasets = ListDatasets()
for ds in datasets:
for fc in ListFeatureClasses(feature_dataset=ds):
print ('adding Edit tracking fields added for {0}'.format(fc))
EnableEditorTracking_management(fc, "Creator", "CreationDate", "Editor", "EditDate", "ADD_FIELDS", "UTC")
DisableEditorTracking_management(fc)
print ('Edit tracking fields added and disabled for {0}'.format(fc))
Then I do this to keep records of previous edit tracking fields
#add edit tracking to all the feature classes AND DISABLE EDIT TRACKING
from arcpy import ListFeatureClasses, ListDatasets, EnableEditorTracking_management, DisableEditorTracking_management, env
#NewDatabase = r'c:\temp\CollectorGDB_2018081502.gdb'
env.workspace = NewDatabase
print (env.workspace)
datasets = ListDatasets()
for ds in datasets:
for fc in ListFeatureClasses(feature_dataset=ds):
print ('adding Edit tracking fields added for {0}'.format(fc))
EnableEditorTracking_management(fc, "Creator2018", "CreationDate2018", "Editor2018", "EditDate2018", "ADD_FIELDS", "UTC")
DisableEditorTracking_management(fc)
print ('Edit tracking fields added and disabled for {0}'.format(fc))
then I do lots of other stuff to download and append and stage the updates, then I do these steps:
#back calculate edit tracking to static fields
from arcpy import ListFeatureClasses, ListDatasets, env, ListFields
from arcpy.management import CalculateField
#NewDatabase = r'C:\temp\CollectorGDB_2018081502.gdb'
env.workspace = NewDatabase
print (env.workspace)
datasets = ListDatasets()
for ds in datasets:
print (ds)
for fc in ListFeatureClasses(feature_dataset=ds):
print (ds, fc)
CalculateField(fc, "Creator2018", "!Creator!", "PYTHON3", None)
CalculateField(fc, "CreationDate2018", "!CreationDate!", "PYTHON3", None)
CalculateField(fc, "Editor2018", "!Editor!", "PYTHON3", None)
CalculateField(fc, "EditDate2018", "!EditDate!", "PYTHON3", None)
this step moves the appended, historical edit tracking to my last year/historical edit tracking, not managed by Esri.
Then I enable edit tracking back on the original edit tracking fields:
#RE-ENABLE EDIT TRACKING with EDIT TRACKING HISTORY
#arcpy.EnableEditorTracking_management("C:\\gisdata\\Railroads\\CollectorGDB_2018080203.gdb\\Railroad\\MastCrossbuckAssembly", "Creator", "CreationDate", "Editor", "EditDate", "NO_ADD_FIELDS", "UTC")
from arcpy import ListFeatureClasses, ListDatasets, EnableEditorTracking_management, DisableEditorTracking_management, env
#NewDatabase = r'C:\gisdata\Railroads\CollectorGDB_2018080203.gdb'
env.workspace = NewDatabase
print (env.workspace)
datasets = ListDatasets()
for ds in datasets:
for fc in ListFeatureClasses(feature_dataset=ds):
print('enable new edit tracking data to fields in {0}'.format(fc))
EnableEditorTracking_management(fc, "Creator", "CreationDate", "Editor", "EditDate", "NO_ADD_FIELDS", "UTC")