How to preserve the document ID in SharePoint 2016 after moving the file to a new location and make sure the new URL is not broken?

Sukrit Kapil 0 Reputation points
2023-03-07T16:53:33.62+00:00

Hi!

There are two use cases when looking to move a file:

  1. Move within the same site
  2. 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:

  1. Why is the document ID URL not working even on moving the file using the Content and Structure option?
  2. 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?
  3. 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! :)

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-03-08T07:00:25.0133333+00:00

    Hi @Sukrit Kapil

    Per my test, I can reproduce your issues. I created a file called testfile0624.txt in resource library, and the id is 60. After move the file to another library, the id of the file changes to 10. When I search the id 10 in the site, I am unable to find the file. And I search the id 60, It will return the old Url of the file before moving.

    User's image

    And after several minutes, I refresh the page, the url turn to the target library

    User's image

    But I am still unable to saerch the file by new id 10. After I check the Document Unique ID, the id is RAYTHEON-503069472-60. The unique id hasn't been changed after moveto might cause the result.

    I feel regretful to inform you that it turns out to be a by-design one. I noticed that some end users have also proposed the same request, it is highly recommended that you can vote this ticket. Many features of our current products are designed and upgraded based on customers’ feedback. With requirements like this increase, the problem may well be released in the future. Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.