I am trying to create unique document sequence values for my document libraries across multiple sites. I'm creating a calculated field "DocumentID" that is based on timestamp and list ID value. Works great upon document upload. However, when updating the properties, ID is not available when editing properties - so the DocumentID field recalculates with the ID value as 00.

How can I keep my DocumentID from updating once the value was been set at creation time?

  • How are you generating it currently? Workflow? Calculated column? Something else?
    – Todd
    Oct 7, 2021 at 21:10
  • I ended up writing a flow triggered on create. The flow takes the hhmmss of the create timestamp, and the last 2 digits of the item's ID value, and creates a unique-ish 8-digit ID value. The only way to create a duplicate across the tenant is if someone drops a file at the exact time of day and it happens to also be the same list count as any previous. (ie: has to be the 22nd item added to the list to match.) Dec 1, 2021 at 15:28

4 Answers 4


Why are you re-inventing the wheel?
Just activate the Document ID feature built into SharePoint.
This is a site collection-level feature, so you must activate the feature in the site collection’s root web Site Settings menu. It is located at: Site Settings —> Site Collection Features

Here is Microsoft’s documentation for this feature.

As for ensuring that the Document ID is rendered with a particular date - SharePoint stores that as metadata. (This is the already invented wheel I referenced above.)

Additional benefits:

  1. Document IDs generated by the system are always unique, even if moved (not if copied) to another site
  2. They are immutable across versions of documents
  3. You don’t need to deal with finicky stateless custom column formulae - it just works
  4. You can even customize elements of the rendered Document ID to a particular site to distinguish its origination.

There is one down-side for you: The internal name of the Document ID column generated by this feature is the same as the one you are already using: ‘DocumentID’. So you may have to delete your existing DocumentID column to accommodate this feature.

  • Thanks for the tip, Fritz. However, enabling DocumentID applies to the site collection. I need something that will apply to the tenant. I ended up using a formula that takes the hhmmss of the create timestamp and the last 2 digits of ID of the item in the document library to forum an 8 digit unique value. It's unique by chance - the only way to duplicate is if a file is posted at the exact same time of day and happens to be the same "ID" in that given library. I have better chances of winning the Powerball. Dec 1, 2021 at 15:19
  • Really? I’m just coming off holiday break this past week and checking out responses. How did you propagate your new document numbering methodology across the entire tenant? I would be interested to know how you did that. Ultimately, the documentation, which I originally quoted above: States that so long as all the sites to which the file moves have the Doc ID feature enabled you would be good. That’s a simple PowerShell script to enable the Doc ID service. How is an iterative PowerShell script, enabling a durable linked document somehow compared to your numbering system? Jan 6, 2022 at 6:12
  • The root problem with your solution is that the ID is a GUID. My staff use the IDs for search and recall. GUIDs are not reasonable for this purpose. Jan 7, 2022 at 14:48

The solution we used was to create a flow script that takes the last two digits of the library item id (a sequential number) and use that as a suffix to hhmmss of create timestamp. It's not TRULY unique across the tenant, but highly probable to never be duplicated. (You have to drop a file on a library the exact same hour/minute/second of a given day AND it has to be the same sequence in the list (43rd document) in order to be duplicated. Very highly unlikely to happen. And if it does - site collection context will assist the seeker of the file to identify which one they are seeking. The flow must be copied and configured to every library that uses the tagging structure - which is unfortunate. This will create dozens of flows (we typically have less than 40 active projects) but a naming convention will facilitate management.

Not the best solution - but it's workable.

  • That sounds like a real headache. Yes, you will probably achieve something close to 99.99% uniqueness in your numbering, but then you need to deploy that library template to every site and web in the tenant, make it the default library template, so when a self-service Smurf comes along and innocently creates a new library .... but you should be able to control that output with PnP provisioning. Cheers! Jan 19, 2022 at 2:24
  • Fritz - absolutely right. In fact - we have TWO for every dedicated library. One that activates when a file is dropped, and one the is scheduled 3x daily to sweep the library in the case the drop-activate fails. But it is noteworthy - we are instructing our peeps that the script applies only to the dedicated library. The library uses a special document template - so our peeps will know that other generic libraries won't have this treatment. Jan 20, 2022 at 13:14

Under Site Settings, there's a feature where you can enable a unique identifier that will apply across all lists/libraries of your site. Now - that may not make them unique across your tenant - but - you have the ability to provide a prefix. So - if your prefix is unique for each site collection - you'll get a unique value across your tenant. The only down-side is the document ID can be up to 10 digits long, followed by the actual list ID sequence value. Add to that a prefix - and you've got a rather long and unwieldy document ID. But --- for what it's worth - it's absolutely unique across the tenant.


The Document ID Service only provides a unique ID per site collection. In SharePoint Online every site is its own site collection. Moving an item to another site collection would need the document ID service enabled on each site and the document would be given a new ID as its not maintained.

SharePoint Online also assigned a unique GUID to a file, but when moving to other site collections, this is also re-generated.

Using a flow to set the Documents file property "UniqueID" with a GUID sets the ID in the file itself, so if moved can be tracked and wont change (unless a use edits it, so make it read-only or a PDF.

You'll need to map the file property unique field as searchable managed metadata say "FileUniqueId" to retrieve it and as long as you have access to it can retrieve it directly from the search box FileUniqueId:{GUID}

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Pradip R.
    May 23, 2023 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.