SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add workflow to my webpart. Whenever items added or removed from webparts my workflow needs to be started. I am not sure what my web part will have - it can have any items like list, controls, etc. Is this possible?

share|improve this question
Your question doesn't make sense - web parts don't 'have' lists and controls don't have workflow. Are you talking about putting a workflow on a list? – Ryan Mar 1 '12 at 8:19
My scenario is whenever particular user edits or create any item inside web part i need to call a workflow and that workflow should decide whether particular user has permission to create or i clear.. – Sanker Mar 1 '12 at 8:42
Clear? Not really. Is the web part a custom web part or the built in ones? What is it creating - is it items in a SharePoint list or something else? – Ryan Mar 1 '12 at 8:44
Custom web part with any type of content.. – Sanker Mar 1 '12 at 8:47
up vote 2 down vote accepted

if it is a webpart you have built you can manualy start and stop the workflow

here is a snippet

   public void StartWorkflow(SPWorkflowManager manager,string eventData,SPListItem listItem,SPWorkflowAssociation workflow)
       SPWorkflowCollection workflows = manager.GetItemActiveWorkflows(listItem);
       if (workflows.Count > 0)
       manager.StartWorkflow(listItem, workflow, string.Empty, true);

WorkFlow Manager Refrence


You will have to create the method that fires the workflow i usualy use an eventreciver of some sort. but as your question is very general i cannot give you a solution for that. but if for example you are displaying a list via a webpart. attatch an event reciver to the list and it will be kicked of if you edit it in the workflow

share|improve this answer
my web part can have any type of content..also if my web part has more than one content then i have to write event receiver for each content.. – Sanker Mar 1 '12 at 8:55
the issue is that your question is very general. but for every type of webpart you would have to code a different even reciver – Sebastien Stettler Mar 1 '12 at 9:07
ok then i have to use event receiver for every content that i use in my web part and from there i have to start my workflow.. – Sanker Mar 1 '12 at 9:10
no, its not realy about the type of content its more about. how the content gets manipulated is it a list is their a form with a submit button etc. because depending on that you will either attach a event reciver or create a custom function. because if you look at the event reciver specs it can only attach to certin events – Sebastien Stettler Mar 1 '12 at 9:45
ok ok i got it..Thanks a lot.. – Sanker Mar 1 '12 at 9:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.