SharePoint Online and Document ID. The Goods.

Reading Time: 5 minutes

I’m currently provisioning modern Team Sites in SharePoint Online and was asked how/if we could uniquely identify a document within a site and tenant. There’s a site collection Document ID feature I’ve used in SharePoint on-premises environments in Classic site collections to do this, however I’d never tried it in SharePoint Online on a Modern Team site. I was curious to see if it worked the same and what the use-case would be for something like this.

Once the Document ID feature is activated, 3 important things happen:

  1. Every document on the site will be assigned a unique Document ID
  2. Every document on the site can be retrieved with a URL of /_layouts/15/DocIdRedir.aspx?ID=<Document ID> and this is rendered as the Document ID (Linked to document) URL column on the All Documents view
  3. You can search for the document by the Document ID and the managed property DlcDocId

The advantage of a Document ID is it won’t change (some caveats – I’ll talk about these). This is beneficial if you want a way of always being able to retrieve a document using the Document ID even if it moves from its original location.

Reference: Document ID Feature

To test out the Document ID feature in a Modern Team site, I wanted to see if either the Document ID value or the Document ID URL changed for any of these scenarios:

Test Cases

Note: I am NOT referring to the Copy link URL you get for any document across your tenant. If you move the document, that will change. Instead, I’m referring to the Document ID URL column created when you enable the Document ID feature.

TDLR? Skip down to the Summary section and I’ll tell you what I found.

Setup

Once the Document ID feature is activated, a new Site Collection setting will appear called Document ID settings (image). This setting allows you to enter a prefix (up to 12 characters) to customize your Document IDs and optionally reset all document IDs in the site collection to inherit the prefix. If you check this option, a timer process will run in the background to do this; typical with any timed process in SharePoint Online, you have no insight into when this will happen but it’s likely a factor of the number of documents you have in your site collection. My experience so far has been within a day the reset will happen.

Document ID Settings

For my test cases, I set the prefix to JOJODOC to force all Document IDs on the site to follow this format:

JOJODOC-9999999999-9

I uploaded 6 documents into the Documents library and all 6 were immediately given a unique Document ID with the prefix:

Test Case documentsThe circled column is a URL column in the format:

/_layouts/15/DocIdRedir.aspx?ID=<Document ID>


Test Results

Folder Move

I created a folder in the Document library above and moved one of the documents into the new folder.

Folder moveSomeOtherFolder

Folder move test results:

  • Underlying Document ID URL link remained the same
  • Document ID remained the same

Library Move

I created another document library in the same site called SomeOtherLibrary and moved one of the documents from above into it. The document ID stayed the same.

SomeOtherLibrary

Sidebar: When I uploaded a brand new document into SomeOtherLibrary, I noticed the number portion of the Document ID it generated was different indicating that portion of the ID is unique to a document library.

Document ID moved to library

Library move test results:

  • Underlying Document ID URL link remained the same
  • The Document ID remained the same

Site Move

I created another Modern Team site called SearchTeam and moved one of the documents from the above into it.

Site move test results:

  • Underlying Document ID URL link changed to point to the new site collection
  • Document ID may change depending on the following…

If the Document ID feature isn’t activated on the destination site, I’m warned of losing properties at the destination… in this case, the Document ID. This behavior is consistent with the warning received when any kind of metadata on a document is not at the destination location.

LoseMetadata on move

If I choose to move the document anyway, the Document ID property will be lost.

If the Document ID feature is activated on the destination site, the Document ID will be carried over in the Move operation, even if you have a different prefix defined on the destination site. In this example, the Document ID prefix I’ve defined at the destination site is JOJONEWDOC, however the old Document IDs are retained:

Document ID on different site

In short, the Document ID can only change if:

  • If you reset the Document IDs on the destination site to reflect its default Prefix, the Document ID will be updated for all documents in the site collection with the timer process, including the ones with the JOJODOC prefix
  • If you move a document with a Document ID to a site collection without the Document ID feature activated, the document will lose its Document ID

Summary

You can use the Document ID to retrieve a document even if it moves out of its original location (folder, library) and even site collection IF the Document ID feature is activated at the destination site as well.

Because the Document ID doesn’t change (unless you’ve intentionally reset it), there are 2 ways you can leverage it to retrieve a document:

  1. Search for it across your Tenant

HowToSearch

Because the Document ID column has a search managed property automatically defined (DlcDocId), you can use it in a search query to retrieve the document from anywhere across your tenant.

  1. Leverage the Document ID column in your views (DocIdRedir.aspx)

You can retrieve a document by its Document ID even if it moves outside of the initial site collection by using the DocIdRedir.aspx page on the site collection it’s in. This is what the Document ID (linked to document) column will use:

/_layouts/15/DocIdRedir.aspx?ID=<Document ID>


What’s the use-case?

In a Classic site, there’s a web part to allow you to retrieve a Document by it’s Document ID, however the equivalent web part doesn’t exist in the Modern world.

FindByDocumentID

You can , however still use the Document ID (linked to document) column on your views to retrieve a specific document or use search directly if you know the Document ID.

This feature could be beneficial in solutions where you need to have a unique identifier for a document however it doesn’t guarantee the underlying Document ID URL won’t change if you’ve moved it to another site or renamed the Document ID – an important distinction.

Thanks for sticking with me. 🙂

-JCK

8 comments

  1. Do you know if the Document ID feature can be turned on for a tenant? Or do you have to enable the feature for each site manually? If it’s possible to enable by default for all sites, would that be a best practice? Thank you for any insight – this post was very helpful!

    1. Hi Curtica, You cannot enable it at the tenant level, must be done at a site collection level. That is not a “best practice”… It is dependent on your use case and why you need a unique document ID in the first place. If you won’t be leveraging it, not much use for it. On collaboration sites, I don’t see it being used, I see it more on a controlled document site however it’s dependent on how/if you plan on using it.
      Hope that helped.
      -JCK

  2. Great article but I think it a real shame that 17 years on from the birth of SharePoint Microsoft till have given us an immutable document id / link feature that works across your SharePoint estate. An additional point worth making is that the document id feature doesn’t work for folders only document sets and the later are not fully supported in SharePoint Online so we are actually going backwards if your want an immutable id for a collection

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.