Wednesday, May 21, 2008

How to remove workflow from List Item

Hi All,

There is a way how we can remove workflow from List Item.

Sometimes we may require to remove workflow from list item. Even to terminate sometime we require to remove workflow. There are certain stage where we are not able to terminate the workflow, there other option is that we remove the workflow from item.

So here is the way we can accomplish this task:

Let us assume that we have workflow attached to a list level. And we trigger the workflow on every update of the Item.

And in our workflow somewhere we require to remove the current workflow if certain action is taken.

So, When you are working with workflow, then it is on Item level.

so writing following code will remove workflow from Item.

workflowProperties.Site.WorkflowManager.RemoveWorkflowFromListItem(workflowProperties.Workflow);


But also make sure that whereever you are referring workflow instance Id, you will lost that link, so take care of that also, because now as workflow is removed, you dont have the workflow instance id.

That's it. Your job is done.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com