Basic Administration > Supporting Collaboration > Workflow Administration > Workflow Tools > Workflow Template Administration > Workflow Code Samples > Synchronize Robot Samples > Synchronize Custom Workflow Events
  
Synchronize Custom Workflow Events
This topic provides a sample of a Synchronize robot node halting a process until a specific user-defined event in another process is fired.
Referenced Workflows
SynchronizationOfUserDefinedEvents.xml
UserEventsWorkflow.xml
Description
You can define a robot so that it halts the progress of a process until a certain user-defined event in another process fires. In the expression below, the robot listens to the ACTIVITY_STATE_CHANGED event of an activity and checks if any of three user-defined events - thermal analysis, fatigue analysis, or stress analysis - have been fired. For each of these events, it has a corresponding event of its own that must be fired, which it adds to the vector: tempResult. Finally, it sets its result to the Vector tempResult. Now the robot fires all the events that the result Vector contains have been fired.
Instructions
Copy the following code:
Vector tempResult = new Vector ();

//Get activity that caused the event
WfAssignedActivity activity = (WfAssignedActivity) (( wt.events.KeyedEvent) event).getEventTarget();

//Check if the activity and process are the one's we're looking for
if (activity.getName().equals(activityName)){

//Check if the Parent process of the activity is the one we are interested in.
if (activity.getParentProcess().getName().equals(processName)){

//Check if the list of events for the activity contains the event "thermal analysis".
//If so, add to the Vector tempResult, the appropriate event to fire for the robot.
if (activity.getAllEvents().contains("thermal analysis")){
tempResult.addElement("thermal analysis");
}

//Check if the list of events for the activity contains the event "fatigue analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("fatigue analysis")){
tempResult.addElement("fatigue analysis");
}
//Check if the list of events for the activity contains the event "stress analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("stress analysis")){
tempResult.addElement("stress analysis");
}
}
}

//Set result to the Vector tempResult.
//Note that in the previous steps, all the events that the robot must fire were added to tempResult.
result = tempResult;