​​How to create a custom unique ID based on SharePoint item ID column?

Last Update: December 27, 2018

Apply for: SPARK Workflow for SharePoint 2013/2016 and Office 365

Suppose you have a list named "Tickets" and you want to create a workflow over this list to generate a custom unique ID for each created item in this list using this format: TKT-00001, TKT-00002, …TKT-00003 (the custom ID can go up to TKT-99999), after that, you want to assign the generated custom ID value to the "Ticket ID" column.

Here are the steps on how to

  1. Create a new list workflow. For more details on how to create a list workflow, refer to Create a list workflow use case.
  2. Drag "Set Activities" activity onto the workflow canvas and drop it onto a design node How to create a custom unique ID based on SharePoint item ID column11.png then drag "Math Operation", "String Builder" and "Update Item" activities inside the "Set Activities" activity and then rename the activities as follows:
    How to create a custom unique ID based on SharePoint item ID column1.png
  3. Configure "Set Activities" activity as follows:
    How to create a custom unique ID based on SharePoint item ID column2.png
  4. Configure "Math Operation" activity as follows:
    How to create a custom unique ID based on SharePoint item ID column3.png
    Note:A workflow variable named "varLeadingZerosCount" of type integer should be created to store the count of leading zeros.
  5. Configure "String Builder" activity as follows:
    How to create a custom unique ID based on SharePoint item ID column3.png
    Note:: A workflow variable named "varTicketID" of type string should be created to store the generate ticket id.
  6. Configure "Update Item" activity as follows:
    How to create a custom unique ID based on SharePoint item ID column4.png
  7. Publish the workflow by clicking on the Publish button in the workflow ribbon.
  8. Now you can test the workflow by adding a new item to the list that this workflow being created on.