I don't have access to InfoPath.

I am making a custom web part with a basic form having 4 fields and a submit button. I want to start a workflow when user presses submit button? Can I do this in my custom form? I mean running some workflow on button click?

2 Answers 2


You can start a workflow programmatically with the code from here

private SPWorkflowAssociation GetWorkflowAssociationByName(SPListItem item, string workflowAssociationName) 
    return item.ContentType.WorkflowAssociations.GetAssociationByName(workflowAssociationName, new System.Globalization.CultureInfo("en-US")); 


public void StartWorkflow(SPListItem item, string associationName) 
//get workflow association object
workflowAssociation = GetWorkflowAssociationByName(item, associationName);                 

if (workflowAssociation == null)
  throw new Exception(string.Format  ("Workflow association '{0}' could not be found in the list '{1}'", workflowAssociationName, item.ParentList.Title)); 

//start your workflow...
item.Web.Site.WorkflowManager.StartWorkflow(item, workflowAssociation, workflowAssociation.AssociationData); 
   catch (SPException spEx) 
   { //log your exception } 

//that kicks off a associated workflow.
StartWorkflow(anInstanceOfSPListItem, "Masood - Approval workflow")
  • Great! What if I want to write my own workflow? Oct 28, 2014 at 9:26
  • You can use SharePoint designer or visual studio.
    – Choggo
    Oct 28, 2014 at 9:41

Look the SPWorkflowManager class. It is available from SPSite.WorkflowManager property. It has StartWorkflow methods to run new workflow instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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