Site icon Joanne C Klein

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:

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.

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:

The 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 move test results:


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.

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.

Library move test results:


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:

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.

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:

In short, the Document ID can only change if:


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

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.

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