sdpawlak

replaceDataSource replaces broken sources and removes non-broken sources??

Discussion created by sdpawlak on Dec 12, 2011
Latest reply on May 22, 2013 by mark.gorecki
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