Convert Sharepoint ID into a number with leading zeros - eg. 12 becomes 0012

Mark Farrant 101 Reputation points
2021-01-21T16:43:42.987+00:00

I would like to use the SharePoint list unique ID value as a unique identifier but I would like to display that value with leading zeros. Currently it is displaying as 1, 20, 130 etc whereas I would like it to display within the views as 0001, 0020, 0130.

The next step will be to concatenate the field with another but I cannot do this until I manage to resolve the leading zero problem.

Any help appreciated as you can tell from the request above I am new to SharePoint.

Microsoft 365 and Office | SharePoint | For business | Windows
{count} vote

Accepted answer
  1. Mark Farrant 101 Reputation points
    2021-01-26T16:37:25.313+00:00

    Hi EchoDU-MSFT,

    Many thanks for your response unfortunately I was looking at a SharePoint list not a document list but I have managed to work it out using:

    =CONCATENATE([Field value],REPT("0",MAX(0,4-LEN(ID))),ID)

    This gave me the leading zeros in front of the unique ID, i.e. 0001 for ID of 1 or 0130 for the ID of 130.

    Regards
    Mark


1 additional answer

Sort by: Most helpful
  1. Echo Du_MSFT 17,316 Reputation points
    2021-01-22T02:23:35.393+00:00

    Hello @Mark Farrant ,

    The prefix of Document ID is an alphanumeric value (no special characters) between 4 and 12 characters.

    A document ID is composed of:

    • The prefix you assign (0000)
    • A nine-digit value assigned by SharePoint for the site (855087005).
    • The unique ID.

    Eg. 12 becomes 0000-855087005-12

    Please follow steps:

    1.Enable Document ID feature

    • Sign in the site as SharePoint admin
    • Go to the Site settings >> (Site Collection Administration) Site collection features >> scroll down to Document ID Service >> click Activate

    59424-1.png

    2.Configure Document ID settings

    • Go back the Site Settings page >> (Site Collection Administration) Document ID settings

    59376-2.png

    • Enter characters in the "Begin IDs with the following characters" textbox to assign a prefix for the Document IDs
    • If you want SharePoint to generate document IDs for all libraries in the site, check the box "Reset all document IDs in this Site Collection to begin with these characters".

    59378-3.png

    3.After the setting is over, it will take a while to take effect

    59356-4.png

    Thanks,
    Echo Du

    ======================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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.

    2 people found this answer helpful.
    0 comments No comments

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.