Hi,
I have a map document which I have imported in ArcGIS Pro. This document contains about 150 query layers. I wish to change the data source for these query layers to a registered view in my database. I was able to do this manually in pro using the Set Data Source functionality. But since there are lot of layers, it is a huge task to update it manually.
I tried the layer.updateConnectionProperties(), but it doesn't seems to work.
Here is my code: (Note I have manually changed the data source for the third layer so that it acts as a source to apply the data source to the remaining layers)
doc=arcpy.mp.ArcGISProject('current')
map=doc.listmaps()[0]
lyr = map.listLayers()[2]
conProp = lyr.connectionProperties
for lyr in map.listLayers():
if lyr.supports("dataSource"):
cp = lyr.connectionProperties
if cp is not None:
if(not cp['dataset']=='MY_VIEW'):
lyr.updateConnectionProperties(cp,conProp)Any help would be appreciated.