Start a Work Flow By Click on Button
SPWorkflowManager objWorkflowManager = null;
SPWorkflowAssociationCollection objWorkflowAssociationCollection = null;
objWorkflowManager = listitem.Web.Site.WorkflowManager;
objWorkflowAssociationCollection = listitem.ParentList.WorkflowAssociations;
foreach (SPWorkflowAssociation objWorkflowAssociation in objWorkflowAssociationCollection)
{
web.AllowUnsafeUpdates = true;
objWorkflowManager.StartWorkflow(listitem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, true);
web.AllowUnsafeUpdates = false;
message = "\\\"Mail has been sent to " + mailUsers.TrimEnd('.') + ", Workflow started.\\\"";
Comments