Programmatically writing to workflow history list. Sharepoint 2010

I have searched around  the internet and there is no simple way found until I came up on a few comments in different blogs. I decided to write my own version.

//Option 1
void WriteToHistoryList(string comment, string outcome)
{

SPWorkflow.CreateHistoryEvent(workflowProperties.Web, this.WorkflowInstanceId, 0, workflowProperties.Web.CurrentUser, new TimeSpan(),
outcome, comment,"" );
}
//Option 2</pre>
void LogToHistoryList(ActivityExecutionContext executionContext, string  msg)         {

((ISharePointService)executionContext.GetService(typeof(ISharePointService))).LogToHistoryList(base.WorkflowInstanceId, SPWorkflowHistoryEventType.WorkflowComment, 0, new TimeSpan(), string.Empty, msg, string.Empty);                     }

&nbsp;
<pre>

4 responses to this post.

  1. Posted by sandy on January 16, 2014 at 9:39 AM

    i was actually looking for this. piece of info.
    this is nice and is working.. thanks

    Reply

  2. […] msdn.microsoft.com/en-us/library/ff798337.aspx Programmatically writing to workflow history list. Sharepoint 2010 […]

    Reply

Leave a comment

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