AnsweredAssumed Answered

Updating Data Source in ArcGIS PRO project with arcpy

Question asked by agelfert on Mar 22, 2019
Latest reply on Jul 31, 2020 by jmoulds-esristaff

Trying to update data source for layers in ArcGIS Pro maps programmatically. So, I must be misunderstanding the syntax for doing that explained here. Because the following does not work:

import arcpy

aprx ='path to my project file')

#This gets me list of all the maps
maplist = aprx.listMaps()

#If I only want those belonging to MyGroup
mygroup = aprx.listMaps('MyGroup')[0]

#To get the layers in that group
grouplayers = mygroup.listLayers()

new_sdeConn = r'path to my SDE connection file'

for lyr in grouplayers:
    old = lyr.connectionProperties     #also tried lyr.connectionProperties['connection_info']
    lyr.updateConnectionProperties(old, new_sdeConn)


This doesn't throw an error. it just doesn't do update the data sources as desired. The ESRI example goes like:



Does this maybe only work for the project as a whole?