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 many methods that we’ve used to deliver such capabilities with success.
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 request. 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 .
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:
- Create a Task list titled Requests
- Add Choice column titled Request Type
- Choices are: Purchase, Support and Leave
- Edit the default view to Group By our field Request Type
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
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.
- Let’s begin with renaming the “Stage” of your workflow that may be something more meaninful 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.
- Next let’s establish some variables for our workflow. In the ribbon you’ll find a button labeled Local Variables. Add the following
- Name: Date
- Name: SPID
- Name: Date
- 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:
- Date = Current Item : Created
- SPID = Current Item : ID
- Once you’ve set the variables, on the next line of your workflow, insert an action to Update List Item.
- Click on the highlighted “this list” text in your new workflow step and in the modal, make sure that Current Item is selected in the dropdown and click Add.
- 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.
- Then in the To This Value field, click the ellipsis and we’ll begin creating our concatenation string of item data.
- In the modal window (String Builder) we’ll click the Add or Change Lookup button and select Current Item : Request Type.
- 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 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 seperation of data visually.
- In the Transition to stage section of your first workflow stage, go ahead and insert an action to Go To A Stage.
- 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.
- For the Create Unique ID stage, in the transition dropdown, choose to go to a stage: Complete.
- 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.
- Finally, add the End Workflow to the transition to stage dropdown for our Complete stage.
- SAVE the workflow!
- Go back to the Workflow Details tab for our newly created workflow and ensure that the box is checked to Start workflow automatically when an item is created.
- Save… and Publish.
Let’s add a few sample items to our list and test the workflow. Add a few items, one for each Request Type so that you can verify your view is working to group the requests by type and your Unique ID (Task Name) includes your Request Type in the resultant concatenated string.
We’ve built a unique identifier for SharePoint list items by way of a SharePoint Designer 2013 workflow. Like I mentioned before, there a lot of methods for accomplishing this same functionality but I believe that working through this solution, has in my experience in the past, opened the eyes of young SharePoint designers to the potential that workflows and the functionality within designer contain. Working with the workflow designer, setting variables, using workflow context and actions can quickly take a budding SharePoint user to Power user. We hope that you find some good information in this post and look forward to any questions you may have regarding this or any other SharePoint features and solutions.