A common requirement for controlled document systems is document numbering or naming. SharePoint includes an out of the box ‘Document ID‘ system which can give you a unique number with a prefix, but it doesn’t provide enough flexibility for many scenarios. In this blog I’ll explain how to use Power Automate to generate document numbers.
Document Naming conventions
Power Automate can concatenate values from lookups or calculations to generate a file name or “number”. For example:
- Doc Type + Next Number e.g. SOP-1234, Guide-1001, HR-103
- Dept + Doc Type + Number e.g. HR-SOP-103, IT-Guide-1001
- some other combination of things to generate a unique value
Power Automate can update the metadata tagged to a document or List item with the value. Once that is done, SharePoint users can filter, group, sort and search based on the value. It can also be inserted into a document using Quick Parts in Microsoft Office.
This example Flow reads data from a List to determine the next available revision letter. For example, the first release of a document is revision A, followed by revision B and so on.
In SharePoint create a list with two columns. The Title column contains the current value and the second column the Next value. For example:
In Power Automate you can use this technique to get the current value and then find the next value. Note the Get Items action uses a Filter Query to return only the next value (make sure the Title column has unique values).
The Update Item action is inside a loop, but will only run once if the Title column is unique. In this case it updates a List item and sets the Revision to the next value, each time the Flow runs.
If you are updating items, a common issue is file locking. This blog explains how to check and wait for file locks https://poszytek.eu/en/microsoft-en/office-365-en/powerautomate-en/locked-file-checking-pattern-in-power-automate/
I hope this helps answer some common questions about document naming or numbering.
2 thoughts on “Document Numbering with Power Automate”
Thanks for sharing some great content.
Instead of using Power Automate to create custom document IDs, have you ever used the Document ID Service in SharePoint to automatically create a custom Document ID based on the Content Type of the template selected followed by an incrementing number?
Hi Ray, yes Document ID is good and I like the permalink it generates. The main issue with Document ID, is the limitations around number formatting. The Power Automate method is good for scenarios where you have a more complex numbering or naming convention e.g. XX-YYYY-NNNN, which is common in controlled document systems. How are you using Document ID?