cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Get Lifecycle State

sdrzewiczewski
7-Bedrock

Get Lifecycle State

In one of my workflows I'm setting the lifecycle state of an object. I've already done some validation that the object's lifecycle template had the target state in it.


I only want to set the state, if the object is not at that target state. Does anybody have a snippet to show me how to get the current state? I'm not seeing what I need in the javadoc, but i'm probably looking in the wrong place.


Thanks,
Steve D.

5 REPLIES 5

On 09/10/12 17:16, Stephen Drzewiczewski wrote:
>
> In one of my workflows I'm setting the lifecycle state of an object. I've already done some validation that the object's lifecycle template had the target state in it.
>
> I only want to set the state, if the object is not at that target state. Does anybody have a snippet to show me how to get the current state?
>

For an epmDocument:
epmDocument epmDoc;
String state = epmDoc.getLifeCycleState().toString();

> I'm not seeing what I need in the javadoc, but i'm probably looking in the wrong place.
>
> Thanks,
> Steve D.
>
>
> ----------


--
------------------------------------------------------------------------
Randy Jones
Systems Administrator
Great Plains Mfg., Inc.
1525 E North St
PO Box 5060
Salina, KS USA 67401
email: -
Phone: 785-823-3276
   Fax: 785-667-2695
------------------------------------------------------------------------

Thanks, it was too simple... 😞

Steve,


Try this. It should be bomb-proof andwill work for any object type



if (<your object=" here="> instanceof wt.lifecycle.LifeCycleManaged) {
String currentState = ((wt.lifecycle.LifeCycleManaged) <your object=" here=">).getState().toString();
}



FYI You don't have to cast your object to LifeCycleManaged in the second line. If it's an instance on LifeCycleManaged it can already do anything a LifeCycleManaged object can do. I added the cast only for clarity.


Hope this helps


Dave



In Reply to Stephen Drzewiczewski:



In one of my workflows I'm setting the lifecycle state of an object. I've already done some validation that the object's lifecycle template had the target state in it.


I only want to set the state, if the object is not at that target state. Does anybody have a snippet to show me how to get the current state? I'm not seeing what I need in the javadoc, but i'm probably looking in the wrong place.


Thanks,
Steve D.


Steve,

It's the getState() method on the objects themselves (WTPart, WTDocument).

Thanks,
Jason Schrader

Got to look at the latest message in the thread. Sorry for the repeat. 🙂

Thanks,
Jason Schrader
Top Tags