In SharePoint 2007, very good feature i like much is that framework supports for writing custom events, features, workflows or any other areas... We can customize complete SharePoint system at any context.
While working with SharePoint custom workflows, we get some scenarios where we need to stop a workflow or start a new instance of workflow. So, i did some research on the MSDN library and saw all the dll's by doing some reflection on the libraries and found some functions and classes which supports this.
Here, i am presenting you guys a small code snippet which does terminating currently running wokflow and start a new instance of the workflow on the same list item.
SPListItem listItem = workflowProperties.Item;
SPList spList = workflowProperties.List;
string initData = workflowProperties.InitiationData;
const string WF_GUID = “The GUID of workflow template”;
workflowProperties.Site.WorkflowManager.RemoveWorkflowFromListItem(workflowProperties.Workflow);
workflowProperties.Site.WorkflowManager.Dispose();
SPWorkflowAssociation associationTemplate= spList.WorkflowAssociations.GetAssociationByBaseID(new Guid(WF_GUID));
workflowProperties.Site.WorkflowManager.StartWorkflow(listItem, associationTemplate, initData);
Monday, April 27, 2009
Subscribe to:
Post Comments (Atom)





0 comments:
Post a Comment