Wednesday, September 21, 2011

View workflow history list

Maybe you would need to view or work with data from your workflow history and for this is useful to know where all logs are stored in SharePoint. Because this list is hidden you need to use way around. Each site where runs some workflow has own history log list.
The URL can look like this: http://[spServer]/[spSite]/Lists/Workflow%20History/[ViewName].aspx

Default view namey is AllItems. This view probably doesn't match your expectation because contain some columns with GUIDs and shows all items of each workflow.
I needed to view just this columns -  User ID, Date Occurred and Description so I have created a new view and used this view in URL.
This will provide you user friendly view but still doesn't solve problem with all items because usually you need to view just some particular items. Here is the method I have used in workflow to get link which shows you just particular item.


        /// <summary>
        /// Returns workflow history list URL and replace space with '%20'
        /// </summary>
        /// <returns>Returns workflow history list URL</returns>
        private string getWorkflowHistoryListUrl()
        {
            string url = this.spRootSite + this.workflowProperties.HistoryListUrl.Replace(" ", "%20");
            //Specify the view
            url += "/UserView.aspx?";
            //Column which contain ID of particular list item where workflow runs
            url += "FilterField1=Item&";
            //Item ID 
            url += "FilterValue1=" + this.workflowProperties.ItemId;


            return url;
        }

If you use better solution, please comment it ;)
At the end, do not forget that SharePoint deletes all records of canceled or completed workflows which are older than 60 days. If you would want to remain history list you can use this link for further information: http://technet.microsoft.com/en-us/library/ee662522.aspx

Hope it helps somebody...

No comments:

Post a Comment