Adding Work Flow History Column in List View Web Part in SharePoint 2010

Requirement: To add a new column in a list, by the name Work Flow History. This is done through a customized solution.

To add a column by the name ” WFHistory” in the List View web part so that they could monitor the status and history of the invoice work flows. Idea was to have a ” url ” in the column so that when user click it, it should route to the work flow history page.



Custom code solution was designed and deployed as wsp Globally at farm level:

Option Explicit On
Option Strict On

Imports System
Imports System.Security.Permissions
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Security
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.Workflow

Public Class EventReceiver1
Inherits SPItemEventReceiver

”’ <summary>
”’ An item was added.
”’ </summary>
Public Overrides Sub ItemAdded(properties as SPItemEventProperties)
Dim li, wfli As SPListItem
Dim web As SPWeb
Dim gid, wfid As Guid
Dim sl As SPList
Dim slid As Integer
Dim wf As SPWorkflow
Dim wfa As SPWorkflowAssociation
Dim filed As SPFieldUrlValue

li = properties.ListItem
If Not li(“Workflow List ID”) Is Nothing Then
web = properties.OpenWeb
gid = New Guid(li(“Workflow List ID”).ToString)
sl = web.Lists.GetList(gid, True)
‘slid = Convert.ToInt32(li(“Workflow List ID”))

wfli = sl.GetItemById(li.ID)

wfid = New Guid(li(“ows_WorkflowInstanceID”).ToString)
‘wf = wfli.Workflows(wfid)
‘wfa = sl.WorkflowAssociations(wf.AssociationId)

filed = New SPFieldUrlValue
filed.Description = “View History”
filed.Url = “/_layouts/WrkStat.aspx?List=” + gid.ToString + “&WorkflowInstanceID=” + wfid.ToString

li(“WFHistory”) = filed
End If
End Sub

End Class


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.