1

Using code from http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000016p000000 trying to enable editor tracking. It works fine if there is no feature dataset in the GDB, but the moment I add a feature dataset in the GDB I get the following error:

[u'QGC_LINK', u'UDM']
Test
Enabling editor tracking on QGC_LINK
Line 60
Failed to execute. Parameters are not valid.
ERROR 000110: QGC_LINK does not exist
Failed to execute (EnableEditorTracking).

It seems that it can't find the file path.

The file structure is as follows:

Test.gdb
Test.gdb/UDM
Test.gdb/QGC_Link
Test.gdb/FD/UDM_1

Code as follows:

import arcpy, os

# Set the workspace
workspace = arcpy.GetParameterAsText(0)

# Set the workspace environment
arcpy.env.workspace = "M:/GIS/Test.gdb/"

# Get all the stand alone tables and feature classes
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses()

print dataList

# For feature datasets get all of the featureclasses
# from the list and add them to the master list
for dataset in arcpy.ListDatasets("", "Feature"):
arcpy.env.workspace = os.path.join(workspace,dataset)
dataList += arcpy.ListFeatureClasses()

print dataset

# Execute enable editor tracking
for dataset in dataList:
print 'Enabling tracking on ' + dataset
arcpy.EnableEditorTracking_management(dataset, "Created", "CreatedDate", "Modified", "ModifiedDate", "ADD_FIELDS", "UTC")
print 'Enabling complete'

1 Answer 1

1

The problem with the code is that you are setting the arcpy.env.workspace to be your geodatabase path + feature dataset name before iterating the feature dataset (good), but this workspace is used then when trying to enable editor tracking on an object not within the feature dataset (not good). Of course the object cannot be found, because arcpy is trying to find a feature class in geodatabase without looking into the feature dataset.

What you have to do is either enable tracking on datasets within feature dataset individually or create a list with the full path to the datasets and then use the elements of this list as "dataset" in the Enable Editor Tracking function. In the code sample below, I iterate over the datasets within the feature datasets first.

import arcpy, os

# Set the workspace
workspace = r"C:\ArcGIS\Default.gdb"

# Set the workspace environment
arcpy.env.workspace = r"C:\ArcGIS\Default.gdb"

# Get all the stand alone tables and feature classes
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses()
print dataList

# For feature datasets get all of the featureclasses    
for dataset in arcpy.ListDatasets("", "Feature"):
    arcpy.env.workspace = os.path.join(workspace,dataset)
    FDdataList = arcpy.ListFeatureClasses()
    print FDdataList

    for dataset in FDdataList:
        print '**Enabling tracking on ' + dataset
        arcpy.EnableEditorTracking_management(dataset, "Created", "CreatedDate", "Modified", "ModifiedDate", "ADD_FIELDS", "UTC")
        print '**Enabling complete'

# Execute enable editor tracking on non-FD objects
arcpy.env.workspace = r"C:\ArcGIS\Default.gdb" #have to set back to the geodatabase!
for dataset in dataList:
    print '**Enabling tracking on ' + dataset
    arcpy.EnableEditorTracking_management(dataset, "Created", "CreatedDate", "Modified", "ModifiedDate", "ADD_FIELDS", "UTC")
    print '**Enabling complete'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.