Customizing Workflow Events on an Object
Creating a customized event on an object
The following is an example of how to create a customized workflow event (wt.workflow.engine.WfCustomEvent) on an object. In this example, the customized event is MY_EVENT.
1. Add the following entry to <Windchill>/src/wt/workflow/engine/WfCustomEventTypeResource.java:
@RBEntry("MY_EVENT")
public static final String MY_EVENT = "MY_EVENT";
2. Add the following entry to <Windchill>/src/wt/workflow/robots/synchEventResource.java:
@RBEntry("MY_EVENT")
public static final String PRIVATE_CONSTANT_39 =
"*/wt.workflow.engine.WfCustomEventTypeResource/MY_EVENT";
* 
Declare the user defined event as a new variable. For example, if the total number of resources available in the synchEventResource.java file are 39, declare MY_EVENT as the 40th variable.
public static final String PRIVATE_CONSTANT_<next_count>=“*/<Classpath>/<Custom_Event>”;
3. Rebuild the resources by running the following in the Windchill shell:
ant -f bin/tools.xml class -Dclass.includes=wt/workflow/robots/synchEventResource.java
ant -f bin/tools.xml class -Dclass.includes=wt/workflow/engine/WfCustomEventTypeResource.java
4. Rebuild the client JARs (see “Rebuilding Client JARs” in Best Practices for Customizing Files Supplied by PTC).
ant -f codebase/MakeJar.xml custUpdate
5. Clear the Java Plug-in cache on your client machines.
6. Restart the Method Server.
7. Use the Workflow Process Editor to design a workflow template with a Synchronization robot, as shown below:
In the Synchronization robot properties window:
a. Select object event
b. Make sure MY_EVENT is listed in Event dropdown list.
c. Choose MY_EVENT
d. Write appropriate expressions in the initial and routing expressions.
For more information on the Workflow Process Editor, see the Basic Administration section in the Windchill Help Center.
Emitting a customized event
Continuing the above example, the following code is required to emit the customized event.
java.util.Hashtable valueMap = new java.util.Hashtable();

wt.workflow.engine.WfEngineServerHelper.service.emitCustomObjectEvent ("MY_EVENT",
primaryBusinessObject, valueMap);
Where:
MY_EVENT is the customized event as created above. Alternatively, any event selected in the Event dropdown list in the Synchronization robot properties window would be substituted in its place.
PrimaryBusinessObject is the object on which we want to emit an event. In other words, the object on which the Synchronization robot is listening for MY_EVENT (the customized event).
* 
A customized event can be emitted from any customized code or from an expression robot.
In handling an emitted event, there is no way to retrieve the valueMap Hashtable from the event, since the synchronization expression syntax does not provide a way to get the event object for an object-based event.
Was this helpful?