I need to start a particular workflow in a list from a timer job. Is there any sample code for starting the workflow in the timer job's Execute() method?


Try this...

public override void Execute (Guid targetInstanceId)
    SPWorkflowManager workflowManager = 
    SPWorkflowAssociationCollection workflowAssociationCollection = 

    foreach (SPWorkflowAssociation workflowAssociation in workflowAssociationCollection)
        if (String.Compare(
                workflowAssociation.BaseId.ToString("B"), {"Workflow GUID"}, true) == 0)
            workflowManager.StartWorkflow("GETYOUR ITEM OR LIST OBJECT",
                        workflowAssociation, workflowAssociation.AssociationData, true); 
  • Hi Vivek, Thank you for this !! However have some questions, In the timer job I have conditions like if the list expiry date is greater than today, I need to send the reminder letter for the group member. Now which type of workflow i need to create? The GUID you mentioned, where I will get? Plz contact me on reenuiss@gmail.com – Jithu Dec 28 '11 at 9:32

Refer my blogpost on this. I have provided sample code.

  • Please don't just add a link. Add the actual content since a link may break in the future. Thx – Benny Skogberg Apr 24 '15 at 4:28

Your Answer

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