sdpawlak

update broken data sources

Discussion created by sdpawlak on Dec 12, 2011
Latest reply on Dec 13, 2011 by jbarrette-esristaff
I'm trying to update my layer's broken data sources within my mxd, but once the broken data sources are updated, the layers that are not broken are removed from my mxd's TOC.

Any Ideas?

#Import arcpy module
import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")
brknList = arcpy.mapping.ListBrokenDataSources(mxd)
for brknItem in brknList:
    arcpy.AddMessage(brknItem)
    arcpy.AddMessage("\t" + brknItem.datasetName)
    item = brknItem.datasetName
    workspace = "Database Connections\sde.sde"
    brknItem.replaceDataSource(workspace, "SDE_WORKSPACE", item)
    
arcpy.AddMessage("done")

del mxd

Outcomes