Start Workflow Using EventReceiver

This is how you can invoke workflow using EventReceiver. You can use this code if you have multiple workflows added and you want certain workflow to be invoked based on your selection in list. In this example i have 2 workflows, sequential and parallel. Based on my selection in list one of this workflow will be invoke. You can read more in this thread

Add Value To List From Workflow

Here is another option if you are looking on how to add value to list from workflow. In this example i put it in a method to seek for checker’s approval. When checker approves, the ‘Date Out’ will be fill automatically with dateTime.Now and will move on to the next task.

Task Is Locked By A Running Workflow

Recently i uploaded my custom form in editform.aspx and when i try to edit it here is the error that i got.  
This happens because workflow that i created is just designed to create task and not update the task that has already been created. Thanks to this blog. Using this code in the custom web part will solve the problem. Use it before updating the task.

This is to make sure that the workflow version number is always equals to 1 before updated.

Getting Value From List in Workflow

There is a time when you need to check if the value in the list is empty or otherwise via workflow. Using this code you can get value of list column and you can check it in workflow.

Let’s say you want to check ‘checker 1’ column in task list. Then you want to assign state according to the value in ‘checker 1’, you can use workflowProperties. WorkflowProperties is an object created from the class SPWorkflowActivationProperties, which make the link between the workflow and the SharePoint context.


Other than that you can use onTaskChanged. Here is an example


This code will check the value of ‘status’ column after any changes occur in ‘ontaskchanged1’ event driven.