Writing workflows implies sometimes having to navigate back and forth through the different activities. For example for taking the message of the last Activity, or taking the Assignee of the next Activity. This post gives code samples for retrieving the last Activity Instance. This is the previous Activity Instance that was completed before the current one. /// <summary> /// Return the last activity instance from the current process instance /// </summary> /// <returns></returns> protected ActivityInstance GetLastActivityInstance() { ActivityInstance activity = CurrentWorkItem.Activity as ActivityInstance ; ProcessInstance processInstance = activity.Process as ProcessInstance ; IList < ActivityInstance > activities = new List < ActivityInstance >(processInstance.Activities); for ( int i = activity.Position - 1; i >= 0; i--) { ...
talk is cheap. show me the code.