Hi!
There are two use cases when looking to move a file:
- Move within the same site
- Move between different sites
We wanted to use the CSOM SharePoint library to move files. I have tried using both manual methods and using CSOM libraries in C# to achieve the desired results. I will mention the outcomes regarding both the cases below.
Moving file within the same site
MoveTo CSOM function
On using the File.MoveTo CSOM function, we noticed that although the document ID remained the same (visible in the Document ID column in the folder/library UI), if we tried to access the document using the document ID URL (by clicking on the three dot menu next to the file), it was not working and giving an error: "No documents with the ID <Doc ID> were found in this site collection."
We found some resources online, that said it takes some time for the server to crawl and update the references to the new document location. But even after trying to access the file after 24 hours, it was giving the same error.
Another article mentioned that the type of file also matters, like Office files such as Excel, PPT, Word etc. might behave differently. These results were tried for .PNG files.
Manually using Content and Structure
After this we tried manually moving the file by going to Site Settings --> Content and Structure. But again we faced the same issue and the document ID URL which was working for the newly uploaded file, was broken even after 24 hours.
Moving file between different sites
Manually using ShareGate 'Copy Content'
We tried using ShareGate to copy and then delete the file between different sites (within the same tenant). ShareGate provides some custom options like either to preserve the document ID or assign it automatically or even enter a custom document ID. We tried all the options, but on preserving the document ID we encountered the same error as above.
When we chose the option to automatically assign the document ID, it assigned it according to the prefix defined in the destination site and the document was accessible through the new document ID URL.
Summary and Questions
In short these are the questions, I have:
- Why is the document ID URL not working even on moving the file using the Content and Structure option?
- How can we have the ideal behavior of keeping the same doc ID and also keep the URL working, so that any places where the document was being referred to, still works?
- Let's assume if we are able to keep the same document ID after moving between different sites, the URL still has a part of the new site in the document ID URL. For example, the doc ID URL changes from
https://<tenant>/<collection>/<source_site>/_layouts/15/DocIdRedir.aspx?ID=<Doc_ID_VAL>
to
https://<tenant>/<collection>/<dest_site>/_layouts/15/DocIdRedir.aspx?ID=<Doc_ID_VAL>
So, any older links using this document ID would break? (I did see some article mentioning that SharePoint takes care of this by redirecting the older URL to the new one)
Any guidance regarding this would be appreciated! Thanks! :)