AnsweredAssumed Answered

Using replaceDataSource with an SDE Feature Dataset\FeatureClass

Question asked by jbarlett on Apr 28, 2015
Latest reply on Apr 29, 2015 by jbarlett

I am trying to change the data source from an FGDB to an SDE feature class.  I can get this to work for an SDE feature class that is not within a feature dataset.  For the life of me, I cannot get this to work for a feature class within a feature dataset.  The script fails on line 15.

The error message:

ValueError: Layer: Unexpected error


I believe I am not correctly  specifying the workspath_path or dataset_name correctly.  The destination dataSource =

Database Connections\sdetest.sde\PIPELINE.BAKKEN\PIPELINE.Pipe    


SDE Connection: Database Connections\sdetest.sde


Feature Class: PIPELINE.Pipe


Any help would be appreciated!


import arcpy
import os
mxd = arcpy.mapping.MapDocument('CURRENT')
ListLayers = arcpy.mapping.ListLayers(mxd)
workspace_path = "Database Connections\sdetest.sde"
dataset_name = "PIPELINE.BAKKEN\PIPELINE.Pipe"
# dataset_name = "BAKKEN\PIPELINE.Pipe"
# dataset_name = "PIPELINE.BAKKEN.PIPELINE.Pipe"
# Source: Database Connections\sdetest.sde\PIPELINE.BAKKEN\PIPELINE.Pipe
for Layer in ListLayers:
    if Layer.supports("DATASOURCE"):
        desc = arcpy.Describe(Layer)

        if desc.catalogPath == "\\\\ftwnas01a\\ProjectsNew\\NatGasOps\\NGOData\\Assets\\Bakken.gdb\\Bakken\\Pipe":
           Layer.replaceDataSource(workspace_path, "SDE_WORKSPACE", dataset_name)