Saturday, September 10, 2011

Getting SPWeb ref inside workflow programmatically

If you want to get SPWeb reference inside the OnTaskChanged_Invoked or Task_MethodInvoking

SPWorkflowActivationProperties workflowProperties= new SPWorkflowTaskProperties();
SPWeb web = workflowProperties.Web;

you can get the SPWeb properties of "SPWorkflowActivationProperties" class.
SPContext or HttpContext will not works inside the SharePoint Workflow.

This single line snippet saved my lot of developing hours to trigger the workflow programmatically.