根据对象状态进行同步
本主题提供了“同步”自动机节点识别文档何时达到指定的生命周期状态的示例。
参考工作流
SynchronizeOn State.xml
说明
该表达式监听文档的状态,并在文档发布时激发。自动机监听的事件是 wt.lifecycle.lifeCycleServiceEvent.STATE_CHANGE,自动机监听的 Windchill 类是 wt.doc.WTDocument。
指示
在工作流模板的 System 文件夹中创建文档。定义名为 docNumber 的变量并赋予其默认值,此值等于您刚刚创建的文档的编号。请注意,此变量为 java.lang.String。
复制下列代码:
//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";
}
}