How to have the Workflow history in notification emails?

If you are designing a BPM solution for your organization, you may be asked by end users to have the workflow history in the notification emails. SharePoint workflows don’t support this feature out-of-the-box and you should use some tricks in order to be able to show the workflow history in the notification emails. To show this trick, we use the custom task process with InfoPath forms in order to design our workflow, so a prior knowledge of custom task process functions, InfoPath and SharePoint workflows are assumed.

Here are the steps you should do:

  1. You should create the required fields in order to store the workflow history information in the document library which you have published your InfoPath forms.
  2. You should modify the custom task process events to store information in these fields.
  3. You should use these fields to show the history information in the notification emails.

We use an aggregation method in order to store and update the history information. In each step when a new task is generated in the custom task process workflow, we will add the new values to the history field which is stored in the document library.

Here are the details.

    1. If you want to show the “Assign To”, “Date” and “Task Outcome” in the history notification emails, you should create these three fields accordingly in the document library which hosts the InfoPath form: “WFAssignToHistory”, “WFDateHistory” and “WFOutcomeHistory”.
    2. Go to the Custom Task Process in SharePoint designer, go to “Change the behavior of a single task” and add the followings in “When a Task completes” event:
        1. Insert an action “Update item in Current Item”

      wfhistory-update fields

      1. Add corresponding fields and values as follows:

 

Field Value
WFAssignToHistory [%CurrentItem:WFAssignToHistory%] [%CurrenTask:AssignTo%]
WFDateHistory [%CurrentItem:WFDateHistory %] [%CurrenTask:Modified%]
WFOutcomeHistory [%CurrentItem:WFOutcomeHistory %] [%CurrenTask:Outcome%]

wfhistory-string builder

    1. Go to “When a Task is pending” and insert an action to send a notification email to the Task assign to person and create the template for the task, you can use designing features to have a better look and feel. Use the WFAssignToHistory, WFDateHistory and WFOutcomeHistory to construct the table.

wfhistory-notification email

  1. You may want to make empty these fields when someone cancel the workflow. If you want, you should go to the “Change the behavior of the overall task process” “When the task process is canceled” and add an action to update list item and make these fields empty.

 

MCSE, PMP, With more than 12 years experience in Microsoft technologies.

Tagged with: , , ,

Leave a Reply