Version: Windchill 13.0
Use Case: I have created a new synchronization robot within one of my workflows. I am trying to make use of the synchronization robot to identify when the object that make use of the workflow is manually assigned to a specific phase within its life cycle. However, I am struggling to identify what syntax the expression needs to be in to achieve this.
Description:
I have been using the Javadoc to try to get an understanding of what syntax the expression needs to be in but have had no success. I have a basic understanding of API classes, objects, members of objects, properties of objects etc. However, I am still struggling to get my head around the documentation. Please can anybody who can help offer a suggestion as to what my expression should be and how the Javadoc can be used to develop the suggested expression?
Solved! Go to Solution.
Hi. I was replicating the solution that Joe suggested to me.
This solution was resolved by creating a new "Execute Expression" robot that preceded the synch robot. The text put into the new robot was "changeLatest = (wt.change2.WTChangeActivity2)primaryBusinessObject;". The function of this robot was purely to initialize the variable. The text included in the synch robot was:
"changeLatestState=changeLatest.getLifeCycleState().toString();
if (changeLatestState.equals( "IMPLEMENTATION" ))
{
result = "Go";
} else {
result = null;
}"
The entries below had to be included in the "Variables" table of the properties of the workflow:
Here's an example that you can adapt. We're doing similar where we have a workflow that will iterate a WTPart, but we use a sync robot to make sure the WTPart isn't in a locked state.
As we implemented it, there are 2 workflow variables used in the sync robot:
Here is how the Synchronize is defined:
The initial expression and routing expression are identical, and look like this:
//Get WTPart current state
partLatestState = partLatest.getLifeCycleState().toString();
if (partLatestState.contains("UNDERREVIEW"))
{
result = null;
}else
{
result = "Go";
}
The only routing event is: "Go"
This sync robot will check if the WTPart is in our locked state, UNDERREVIEW, (that's the internal name, by the way) and if it is, it will wait until the WTPart is out of that state.
Hope that's helpful!
Hi Joe. Thank you very much for getting in touch. The process you have described certainly makes sense and aligns with what I am trying to do. I have a question though. You appear to use the "getLifeCycleState" method with the "partLatest" object. How were you able to identify that this method could be used with the type of object that "partLatest" is assigned to? I'm interested in gaining a better understanding of how this information can be determined in the Javadoc to help me understand how best to take advantage of the Javadoc to develop expressions.
I have implemented your config into my workflow. However, I am using the "changeLatest" and "changeLatestState" variables since I am working with a sub-type of a "Change Activity". My variables are configured as seen below:
My initial and routing expression can be seen below. I have used the "Check Syntax" button to ensure that the Syntax is correct:
changeLatestState=changeLatest.getLifeCycleState().toString();
if (changeLatestState.contains("IMPLEMENTATION"))
{
result = "Go";
}
else
{
result = "null";
}
When I put my sub-type of change activity onto this workflow and open up the "Process Manager", I am able to see that I have an error under the synch robot activity that I have configured. The error message says "Target variable was not initialized changeLatest". After looking into this, I can see that variables can be initialized from the "Transitions" tab accessed via the properties of the workflow template.
Are you aware of having to do anything to initialize the variables you have used? I'm wondering if I can use your approach to initialize my wt.change2.WTChangeActivity2 variable
Why are you using “.contains” method and not “.equals” method.
Seems if your waiting for the state to be exactly “UNDERREVIEW” .equals would be bombproof whereas .contains would be satisfied if the state were any string that includes UNDERREVIEW. No?
Hi. I was replicating the solution that Joe suggested to me.
This solution was resolved by creating a new "Execute Expression" robot that preceded the synch robot. The text put into the new robot was "changeLatest = (wt.change2.WTChangeActivity2)primaryBusinessObject;". The function of this robot was purely to initialize the variable. The text included in the synch robot was:
"changeLatestState=changeLatest.getLifeCycleState().toString();
if (changeLatestState.equals( "IMPLEMENTATION" ))
{
result = "Go";
} else {
result = null;
}"
The entries below had to be included in the "Variables" table of the properties of the workflow:
Glad to see you took my advice and used .equals rather than .contains
That's definitely the right call. 👍