This one was a little hard to track down. How do you write directly to the SharePoint workflow history? It’s easy enough to add a LogToHistory activity and set the HistoryDescription and HistoryOutcome, but what if you want to create those entries dynamically?

After toying around with different ways of trying this, the answer was pretty easy:

Here’s the code sample:

SPMember usermember = workflowProperties.OriginatorUser;
SPWorkflow.CreateHistoryEvent(this.workflowProperties.List.ParentWeb,
this.workflowId,
0,
usermember,
TimeSpan.MinValue,
“Corp Legal Reviewed”,
“Status Change”,
string.Empty);