This code successfully completes inside the ArcMap Python window but fails as a script with identical code in a toolbox. The source data is a collection of feature classes directly inside an enterprise geodatabase.

import arcpy
from arcpy import env

env.workspace = "Database Connections\\ClevestDataReload (As SA on GIS).sde"

# Enable archiving on feature classes and tables
arcpy.AddMessage("Beginning to enable archiving on feature classes and tables...")

featureTable = ["CapacitorBank", "DynamicProtectiveDeviceBank"]
iter = 0
while (iter < len(featureTable)):
    arcpy.AddMessage("   Starting to enable archiving on " + featureTable[iter] + "...")
    archiveString = "Database Connections/ClevestDataReload (As SA on GIS).sde/ClevestDataReload.DBO." + featureTable[iter]
    arcpy.AddMessage("   Finished enabling archiving on " + featureTable[iter] + ".")
    iter += 1

arcpy.AddWarning("Completed enabling archiving on all feature classes and tables.")

Here's the error from the script:

Traceback (most recent call last):
  File "C:\Users\zbettis\Desktop\EnableArchiving.py", line 15, in <module>
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 73, in Enable Archiving
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
Error 001540: Enable archiving is not supported for a dataset in a feature dataset.
The feature dataset containing the dataset must be enabled for archiving.
Failed to execute (EnableArchiving).

Failed to execute (EnableArchiving).

enter image description here

  • 2
    Have you tried enabling archiving on your feature dataset? (I'm just reading the error message)
    – PolyGeo
    Jul 13, 2016 at 22:18
  • I would paste in the full Path to the Database Connections folder for env.workspace and the other line, archiveString
    – klewis
    Jul 13, 2016 at 22:41
  • why did this question receive so many downvotes?
    – ziggy
    Mar 31, 2017 at 4:37

1 Answer 1


While I believe the error is correct and you shouldn't be able to enable archiving on an individual Feature Class (FC) within a Feature Dataset (FD), you can get around this in three ways (that I've tested so far). I'll outline what should be happening, and also what I found in my testing.

Everything in a FD is done as a group (the entire dataset) - Spatial Reference, Versioning, Archiving, etc., you cannot (or shouldn't be able to) enable archiving on individual feature classes in a FD.

Enable Archiving option not present at FC level within a FD:
enter image description here

Enable Archiving option available at FD level:
enter image description here

If I run your script from the python window it completes successfully. Also if I run it straight from python (outside of ArcGIS Desktop) it completes successfully. The screenshot below is the properties of a FC within my FD - the FC was enabled using the script, the rest of the FD was not enabled:
enter image description here

You can see now at the FD level that I have both Enable and Disable options!
enter image description here

Running your script from a tool in ArcGIS I get the same error as you:

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 001540: Enable archiving is not supported for a dataset in a feature dataset. The feature dataset containing the dataset must be enabled for archiving.
Failed to execute (EnableArchiving).

However, if I changed my tool to run in the background it ran successfully.
enter image description here

Executing: xxTestArchiving
Start Time: Thu Jul 14 19:40:48 2016
Running script xxTestArchiving...
Completed script xxTestArchiving...
Succeeded at Thu Jul 14 19:40:55 2016 (Elapsed Time: 7.44 seconds)

So, in order to get your script tool to work you could set your tool to run in the background.

That said, I don't believe this is how it's supposed to work, and there could be potential for errors to occur, so use at your own risk!

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.