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

Standard

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.

workflow001

workflow002

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)
MyBase.ItemAdded(properties)
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
li.Update()
End If
End Sub

End Class

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s