I'm using ArcGIS Desktop 10.3.1 in a Citrix environment. I am working on a script that will automate preparing an MXD to publish as a service. One of the requirements is that all our layers point to UNC path data sources, but all of our corporate data is managed using mapped letter drives. So I need to repoint the layers.
I have folder connections to the data source using the mapped letter drive and the UNC path. However, when I use the "Set Data Source" method from the layer properties, it stays mapped to the letter drive path!
So, I used arcpy mapping to create a layer object for that layer, and use the findAndReplaceWorkspacePath and replaceDataSource method to try to point it to the UNC path. No dice: the path still has the mapped letter drive and not the UNC path.
Then I tried a workaround. I created a new, empty file geodatabase and exported all of the layers in my map to that workspace. Then I closed the map document and deleted the file geodatabase. I opened up the map (all the layers were broken) and repointed to the UNC path. Finally, that worked.
However, when I try to replicate that workflow in arcpy, I wind up with mapped letter drives in the workspace path again. Any suggestions on how to resolve this?
If not, perhaps you could go to this idea and upvote it! This seems like a pretty significant bug.
I have a python addin /blogs/myAlaskaGIS/2015/08/31/python-addin-for-data-inventory-and-broken-link-repair That will allow you to do this. Take a look at the sample.xls I have to see some of the "broken path" and "new path". If you run the "3a-Create Unique list of Broken Links" from a machine that you know doesn't have the correct path, the .xls file will be created, then you just correct the paths.
If you don't want to use the tools, you can just unzip and take a looks at the scripts and how I handled it. Might give you some ideas on what you need. Been a while since I've worked on this tools, so don't remember the specifics.
Thanks Rebecca. To clarify - I am not trying to fix broken links. What I am trying to do is consistently repoint existing links from a mapped drive to a UNC path. From what I can tell the addin will only fix broken links. Is that correct?
yes, but as I mention in my notes, broken is in the eye of the beholder, meaning, run the broken link tool from a machine that doesn't have the same drive letter mapping and they will come up as broken. If you notice, the first couple tools only create output "report" files so you can test to see.
But if you can't make them appear broken, you can look at the tool's script and maybe see how I am using the replacement for UNC paths.
By the way, as always, test on a copy of the mxd , not the originals.