Online Training On SharePoint
                      

Friday, 4 June 2010

Start SharePoint Workflows with Intiation Parameters Programatically

To start the SharePoint workflows programatically by passing the initiation parameters following code can be used:
static void Main(string[] args) 
{ 
    using (SPSite spSite = new SPSite("http://localhost")) 
    { 
        using (SPWeb spWeb = spSite.RootWeb) 
        { 
            SPWorkflowAssociation workflowAssociation = spWeb.WorkflowAssociations.GetAssociationByName("WorkflowDemo",CultureInfo.InvariantCulture); 
                    
            if (workflowAssociation != null) 
            { 
                SPWorkflow siteWorkflow = spSite.WorkflowManager.StartWorkflow(spSite, workflowAssociation, "<Data><CompanyID>zzz</CompanyID></Data>", SPWorkflowRunOptions.Asynchronous); 
            } 
        } 
    } 

    Console.WriteLine("Workflow Started with the Initiation Parameter"); 

    Console.Read(); 
}
Post a Comment
Related Posts with Thumbnails