I'm trying to replace the datasource for all of the layers in my map document using Python but I keep running into an error. Right now, all of the layers point to a feature class called GISDB.DBO.TESTFEATURECLASS and I want them to point to a view that I built using the sdetable -o createview command. It has both the object id and geometry columns from the original feature class. It shows up in ArcCatalog with the same icon as a feature class and I can add it as a layer in ArcMap.
Runtime error <type 'exceptions.ValueError'>: Layer: Unexpected error
mapdoc = arcpy.mapping.MapDocument("CURRENT")
workspace_path = r'Database Connections\TestGIS.sde'
workspace_type = "SDE_WORKSPACE"
dataset_name = r'GISDB.DBO.TESTFEATURECLASS_VIEW'
for layer in arcpy.mapping.ListLayers(mapdoc):
layer.replaceDataSource(workspace_path, workspace_type, dataset_name)
How can I determine which property is causing the error?