Customizing Workflow Events on an Object
* 
If you are migrating from a previous release of Windchill, follow the instructions given in Migrating Customized UI Strings to migrate your existing UI text for custom events.
Creating a customized event on an object
You can create a custom event using the Text Tailoring utility or by updating the Java resource bundle files. However, it is recommended that you use the Text Tailoring utility.
Recommended method
The following is an example of creating a custom event MY_EVENT.
1. Access the Text Tailoring utility. For more information, see Text Tailoring Utility.
2. Select the synchEventResource resource bundle that supports adding special characters to your custom event name. For more information, see Selecting Text for Initial Customization.
3. Create a string for your custom event in synchEventResource. For more information, see Creating a String.
Specify the following properties for the string:
KeyMY_EVENT
ValueMY_EVENT
ALIAS*/wt.workflow.engine.WfCustomEventTypeResource/MY_EVENT
The Alias property is used to specify special characters in the string name.
4. Use the workflow template editor to design a workflow template with a Synchronize robot.
a. In the Synchronize robot properties window, on the Synchronize tab, click Object Event.
b. In the Event list, select MY_EVENT.
c. Specify the appropriate initial and routing expressions.
For more information, see Workflow Template Editor, Synchronize Robot.
Legacy method
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 template editor to design a workflow template with a Synchronize robot.
a. In the Synchronize robot properties window, on the Synchronize tab, click Object Event.
b. In the Event list, select MY_EVENT.
c. Specify the appropriate initial and routing expressions.
For more information, see Workflow Template Editor, Synchronize Robot.
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();

public static final WfEngineServiceSvr service = (WfEngineServiceSvr) ManagerServiceFactory.getDefault().getManager (WfEngineService.class);
service.emitCustomObjectEvent ("MY_EVENT",primaryBusinessObject, valueMap);
Where:
MY_EVENT is the customized event as created above. Alternatively, any event selected in the Event 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.
War dies hilfreich?