Sometimes is needed to create workflow history event. This code creates a new history event for each item in the list (the items which are associated with some workflow, of course :) ). This code is not useful at all I think :) so change the code according to your requirements.
using (SPSite site = new SPSite("http://spServer/"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Tasks"];
foreach (SPListItem item in list.Items)
{
foreach (SPWorkflow wf in item.Workflows)
{
//Log to the history list
wf.CreateHistoryEvent((int)SPWorkflowHistoryEventType.TaskCreated, 0, wf.AuthorUser, "", "Task was created.", "");
}
}
}
}
Happy codding ;)
No comments:
Post a Comment