Update June 6, 2012: If you would like to know how to do this in SharePoint 2010, click here for a video tutorial.
It seems that few SharePoint users are happy with the out-of-the box task notifications. While they serve their purpose, we often want highly customized emails that contain more information about the task.
I recently created a workflow that used the Collect Data from a User activity. When you go through the Custom Task Wizard, SharePoint Designer creates a Content Type (based on the parameters you selected) in your site and adds that content type to the Workflow Tasks list for the site. The task notifications use the standard template though and look like this:
So, in this example, Alan needs to correct something in inventory. He can see that an item called “Shipped to Dan’s Bikes” created the task, but he really doesn’t have any idea what he needs to correct, or why he needs to correct it. He could probably figure it out if he clicked on the link to Shipped to Dan’s Bikes, but that’s not very intuitive and still means more work for Alan. If he clicks on the link to Edit this task, he doesn’t get much more details there:
Alan would like to receive an email with all the details he needs and a link to this form to enter his count.
We’ll need to do a few things to replace SharePoint’s default notification with our own. The first thing we need to do is turn off SharePoint’s default notification. On the Workflow Tasks list, go the Advanced Settings and select No for Send e-mail when ownership is assigned.
Next, you’ll need to launch SharePoint Designer, open the site, and create a new workflow.Attach the workflow to your Tasks list and select the option to run when a new item is created.
It’s possible that your Tasks list could contain multiple types of content types, so you’ll want to add conditions in your workflow for each Content Type or create separate workflows for each Content Type. My Content Type was called Inventory Correction, so I check for that in my first condition:
I want my email notification to contain some details about the task and be less generic than the out of the box notifications. You’ll remember that notification just said, “Tasks – Inventory Correction Has Been Assigned To You.” I would like it to say, “New Task: Correct Inventory for the Appalachian Mountain Bike” so that the recipient had a better idea of what he had to do. So, the first action I added to my workflow was Build a Dynamic String. In the String Builder, I typed in the my static text and added a Lookup to get the name of the bicycle from the list item on which the workflow was running that created the task. To find this I matched the Current Item: Workflow Item ID with the ID of the item in the Inventory Adjustments list (that is the list that triggered this task to be created). The lookup looked like this:
So, another important lesson here is that the Workflow Item ID always matches the ID of the item on which the workflow was running that created the task, so it can be used to get to any of that information. Sweet!
Next, I added an action to my workflow to Send and Email. In the Define E-mail Message dialog, I set the subject line to be the Dynamic String I just created.
I also wanted a link directly to the form to edit the task. So, I opened up an existing task and copied the URL for it from my address bar. I added some HTML anchor tags to my email and pasted this URL in as the HREF. I also needed to Look Up to change the ID for the task.
In the body of the email, I used the Workflow Item ID to do lookups on the Inventory Adjustments list to dynamically populate the Bicycle Type, who created the adjustment that caused the problem, and the original adjustment amount. Here is what my completed dialog looked like.
Finally, I wanted to change the Title of the task in the task list to provide more information. I used the Set Field in Current Item activity to change the Title to be the same thing as the subject line of the email. Here is what the complete workflow looked like:
When this workflow runs, it changes the Title of the task from the default “Inventory Correction” (which is the name of the Content Type) to “New Task: Correct Inventory for the Appalachian Mountain Bike.”
If you want to learn more about how to take you SharePoint Designer workflows to the next level, be sure to sign up for our Mission: Automation – SharePoint Workflow and InfoPath class! Hopefully I’ll see you there!