Creating Unique Identifiers in SharePoint 2013 Lists via Workflow

Throughout many of our customer projects, there have been multiple requests to deliver a unique identifier for lists and libraries. These projects have been for internal help desk solutions, Goods and Services Request Centers, Case Management solutions, etc. I’d like to share one of the many methods that we’ve used to deliver such capabilities with success.

The Scenario

For the purposes of this walkthrough let’s assume that we’re working on a Request list that takes various types of requests from employees and allows them to input some very basic information about their requests. Our goal is to allow members of our company to submit requests to a centralized repository and then to have their requests categorized and uniquely identifiable by way of the Title of the request. We’re going to implement this solution by developing a SharePoint 2013 workflow that updates the Task Name field on item creation with a concatenation of data from our item. Specifically, we’ll concatenate the Request Type, Created date, and the listID number for our item.  The end result should look something like this example: [Purchase] - 3/31/2016 - 2 .

The Prep

To prep our Request list for the workflow and to provide a very basic level of demonstration content, we’ve configured our list with the following specs:

  1. Create a Task list titled Requests
  2. Add Choice column titled Request Type
    • Choices are: Purchase, Support, and Leave
  3. Edit the default view to Group By our field Request Type

Optional

I like to hide the Task Name field from my forms so that users don’t feel that they can change the name of our list items. Instead, our workflow will generate this for us after it completes. Even though I hide this from our forms, the field is still easily accessible to list views and at the top of the forms as the title.

  • Go to your list settings > Advanced Settings and Allow Management of Content Types
  • Then back on your list settings page, click on the Task content type and then on the Task Name column.
  • Set the column to Hidden and click ok.

The Nitty Gritty

The first thing we’ll do is open up SharePoint Designer 2013 and connect to our site that contains or will contain the Requests list we’ll be working with. I’ve gone ahead and created a site called Workflow Demo Site and created a list called Requests based on the Task list template.

Once you’ve connected Designer to your site, open up the list that you’ll be working in. i.e. Requests list.

CREATE THE WORKFLOW

Create a new List Workflow associated with the Requests list.

The workflow designer will open up and you can begin entering the steps you want your workflow to walk through.

    1. Let’s begin with renaming the “Stage” of your workflow that may be something more meaningful than “Stage 1”. I’ve renamed the stage to Create Unique ID. Stages can help you identify what stage of your workflow an item currently resides in if you have many.
    2. Next, let’s establish some variables for our workflow. In the ribbon, you’ll find a button labeled Local Variables. Add the following
      1. Name: Date
        Type: Date/Time
      2. Name: SPID
        Type: Number

              1. Then in the first row of your workflow, you can insert an action to Set Workflow Variable. Set Workflow Variable for Date and SPID. Set:
                1. Date = Current Item: Created
                2. SPID =  Current Item: ID
                3. Once you’ve set the variables, on the next line of your workflow, insert an action to Update List Item.
                4. Click on the highlighted “this list” text in your new workflow step and in the modal, make sure that the Current Item is selected in the dropdown, and click Add.
                5. In the Value Assignment dropdown, you can select the field that you would like to make the container for your unique identifier. We’re using Task Name as the field to update.
                6. Then in the To This Value field, click the ellipsis and we’ll begin creating our concatenation string of item data.
                7. In the modal window (String Builder) we’ll click the Add or Change Lookup button and select Current Item: Request Type.
                8. Then we’ll add our variables as we created in the beginning. Click on Add or Change Lookup again and this time change the Data Source dropdown to the Workflow Variables and Parameters choice. The Field from the source dropdown below will now be populated with your two variables created in step two. Go ahead and add both of your variables to the String Builder window. I selected Short Date for the format of my Date Variable and String for the format type of my SPID variable. Within the String Builder window, you can type in any formatting you may want to build your unique identifier with. For instance, I’ve wrapped the Request Type with brackets such that in my list view, the Request Type is easily identifiable. You’ll notice in the example, I’ve also formatted the space between each field being concatenated with dashes to add some separation of data visually.
                9. In the Transition to stage section of your first workflow stage, go ahead, and insert an action to Go To A Stage.
                10. Now click outside the first stage box and you can add a new stage from the ribbon. Give your new stage a name.  i.e. Complete.
                11. For the Create Unique ID stage, in the transition dropdown, choose to go to a stage: Complete.
                12. In the last stage (Complete), I’ve only added one action and that was to Log a message. I’ve instructed it to log the message: “Updated Task Name: and inserted the Task Name field. This allows us to review workflow history and identify possible breaking points if things go wrong.
                13. Finally, add the End Workflow to the transition to stage dropdown for our Complete stage.
                14. SAVE the workflow!
                Pheww!  Much easier to do than type, I promise.  We have created all of the necessary steps and now we just need to ensure that the settings for the workflow trigger are set correctly.

            Go back to the Workflow Details tab for our newly created workflow and ensure that the box is checked to Start the workflow automatically when an item is created.