locked
Sharepoint 2007 - Programmatically Start Workflow Async RRS feed

  • Question

  • Hi,

    I have trying to start a workflow programatically from c# in an asynchronous way.

    Would someone please help me find a solution to this problem?

     

    Here is the code I use to start the workflow:

         //Start the workflow(s)
         SPWorkflowManager oWfManager = null;
         SPWorkflowAssociationCollection oWfAssocColl = null;
         oWfManager = _myTeamSite.Site.WorkflowManager;
    
         oWfAssocColl = oCurrentItem.ParentList.WorkflowAssociations;
    
         foreach (SPWorkflowAssociation objWorkflowAssociation in oWfAssocColl)
         {
          if (String.Compare(objWorkflowAssociation.BaseId.ToString("B"), this.WfGUID, true) == 0)
          {
           if (oWfManager.GetItemActiveWorkflows(oCurrentItem).Count == 0)
           {
            SPWorkflow w = oWfManager.StartWorkflow(oCurrentItem, objWorkflowAssociation, objWorkflowAssociation.AssociationData, true);
            //The above line will start the workflow...
           }
           else
           {
            //Something went wrong!
            CustomValidator1.ErrorMessage = "Attempted to start a workflow on an item that already had an active workflow running on it! Please report this to the administrator.";
            CustomValidator1.IsValid = false;
            CaughtError = true;
           }
           break;
          }
         }
    

    Thanks to all,

    Jimpesh-


    • Edited by Mike Walsh FIN Wednesday, June 15, 2011 6:55 AM SP 2010 comment removed. Pressure (how long worked on) removed. Don't push.
    Tuesday, June 14, 2011 7:59 PM

Answers