Synchronize on the State of an Object
This topic provides an sample of the Synchronize robot node recognizing when a document reaches a specified life cycle state.
Referenced Workflow
SynchronizeOn State.xml
Description
The expression listens for the state of a document and fires when the document is released. The event that the robot listens to is wt.lifecycle.lifeCycleServiceEvent.STATE_CHANGE , and the Windchill class that the robot listens to is wt.doc.WTDocument.
Instructions
Create a document in the System folder in the workflow template. Define a variable called docNumber and give it a default value equivalent to the number of the document you just created. Note that this variable is a java.lang.String.
Copy the following code:
//fetch the object that emitted the State_change event.
wt.doc.WTDocument targetObject = ( wt.doc.WTDocument ) ((wt.events.KeyedEvent) event).getEventTarget();

//Set the result to null so the robot keeps running until the condition is satisfied.
result=nul

l

//check if the object that emitted the state_change event is the same document that the Robot is looking for.
// docNumber is a variable that holds the number of the document that the Robot is looking for.

if ( targetObject.getNumber( ).equals ((( wt.doc.WTDocument ) primaryBusinessObject). getNumber ())){

//check if the document has been released. If so, fire the next activity else the result is null so the robot keeps running //in the background.
if ( targetObject.getLifeCycleState ().equals ( wt.lifecycle.State.RELEASED )){
result = "released";
}
}
Was this helpful?