HOw tO Start YoUr WorKFlow Manually ?

to start a workflow on an SpListItem you will need to write the following code ;

SPListItem currentItem = //Your Item To start the workflow on it;

currentItem.Web.AllowUnsafeUpdates = true;


SPWorkflowManager wfManager = currentItem.Web.Site.WorkflowManager;


SPWorkflowAssociationCollection wfAssociation=

currentItem.ParentList.WorkflowAssociations;



foreach (SPWorkflowAssociation Association in wfAssociation)

{

if (Association.Name == "WorkflowName")

{

wfManager.StartWorkflow(currentItem, Association,Association.AssociationData);

break;
}

}


Try it , but notice that you cant start a workflow from another workflow , you must postback to start the workflow , you can make a form with a button to start the workflow ...


Ebook Download
View all
Learn
View all