Basic Administration > Supporting Collaboration > Workflow Administration > Workflow Tools > Workflow Template Administration > Workflow Code Samples > Routing Samples > Branching on Life Cycle States
  
Branching on Life Cycle States
This topic provides a sample for routing a business object based on its life cycle state.
Referenced Workflow
BranchOnLifeCycleState.xml
Description
This sample demonstrates how to trigger different activities based on the life cycle state of an object. You might have a workflow template that has to perform Task A if Object 1 is in the InWork state and Task B otherwise. The primaryBusinessObject is assumed to be life cycle managed.
Instructions
Replace the <routing event> tags with the ones you want to define for your workflow template and the <life cycle state> tags with the life cycle state from which you want to branch. (The routing type for this activity is Conditional.)
For possible states of a life cycle managed object, refer to wt.lifecycle.StateRB.java.
Copy the following code:
if ((( wt.lifecycle.LifeCycleManaged )primaryBusinessObject). getLifeCycleState( )== wt.lifecycle.State. < life cycle state>)
result= "< routing event >";
else
result= "< routing event >";