Skip to main content
1-Visitor
July 11, 2018
Solved

how to set the lifecycle state of wtpart using API

  • July 11, 2018
  • 1 reply
  • 13337 views

I am trying load a wtpart into windchill through API's and i would like to know how to set the lifecycle state of the part to a specific state.

Best answer by aashishramchand

Hey @RandyJones ,your solution is right , but we have to first store the new part which we created and the change its life cycle state.

 

 

1 reply

20-Turquoise
July 11, 2018

@aashishramchand wrote:

I am trying load a wtpart into windchill through API's and i would like to know how to set the lifecycle state of the part to a specific state.


The LifeCycleHelper class is used for this. eg

String myState = "PROTOTYPE";

WTPart myPart = <already defined>;

LifeCycleHelper.service.setLifeCycleState((LifeCycleManaged) myPart, State.toState(myState));

1-Visitor
July 12, 2018

I tried that and getting this error.

 

 

 

Exception in thread "main" (wt.fc.fcResource/0) wt.util.WTException: The operation: "setLifeCycleState" failed.
Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method; nested exception is:
java.rmi.ServerRuntimeException: Server exception; nested exception is:
java.lang.NullPointerException
at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:788)
at wt.services.ServiceFactory$ClientInvocationHandler.invoke(ServiceFactory.java:349)
at com.sun.proxy.$Proxy13.setLifeCycleState(Unknown Source)
at ext.ttl.LoadPart_test.injectWTPart(LoadPart_test.java:118)
at ext.ttl.LoadPart_test.main(LoadPart_test.java:77)
Caused by: java.lang.NullPointerException
... 5 more

 

 

20-Turquoise
July 12, 2018

@aashishramchand wrote:

I tried that and getting this error.

 

 

 

Exception in thread "main" (wt.fc.fcResource/0) wt.util.WTException: The operation: "setLifeCycleState" failed.
Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method; nested exception is:
java.rmi.ServerRuntimeException: Server exception; nested exception is:
java.lang.NullPointerException
at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:788)
at wt.services.ServiceFactory$ClientInvocationHandler.invoke(ServiceFactory.java:349)
at com.sun.proxy.$Proxy13.setLifeCycleState(Unknown Source)
at ext.ttl.LoadPart_test.injectWTPart(LoadPart_test.java:118)
at ext.ttl.LoadPart_test.main(LoadPart_test.java:77)
Caused by: java.lang.NullPointerException
... 5 more

 

 


This is an issue with your setup. You apparently are not running this on Windchill itself eg: jsp page, workflow, etc.

See this article for running code from a java client:

https://www.ptc.com/en/support/article?n=CS79047