The arcpy layer function layer.replaceDataSource(targetworkspace, "SDE_WORKSPACE",newDataset, False) works perfect when the newDataset is a SDE feature class. But it does not work with feature dataset\featureclass. For example, if I want to reset a layer's data source from sde1.sde\OWNER1.featuredataset\OWNER1.featureclass to sde2.sde\OWNER2.featuredataset\OWNER2.featureclass, the following function call does not work:
layer.replaceDataSource(sde2.sde, "SDE_WORKSPACE","OWNER2.featuredataset\OWNER2.featureclass, False) .
It changes the layer's target sde workspace to sde2.sde, but does not change the dataset owner to be OWNER2. The layer.dataSource is "sde2.sde\OWNER1.featuredataset\OWNER1.featureclass", rather than "sde2.sde\OWNER2.featuredataset\OWNER2.featureclass" which is what I expect to be. Any idea how to do this correctly?