Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hi,
I have a workflow that requires that the life cycle of an object be reassigned in some instances. Currently I have a task that gets sent to the relevant user notifying them that they must reassing the life cycle of the object. Is there a way that I could use a robot in the flow that when a particular routing is fired then the pbo's lifecycle is reassigned?
Thanks.
Solved! Go to Solution.
From screen shot it seems like you want to restart same workflow process i.e. set the state of POB to open so workflow will be trigger, in that case you can use set state robot to change state to Open (See screen shot)
If you want to reassign any other lifecycle then you can add below line
You can read the documentation related to API from below file
[Windchill_Home]/codebase/wt/clients/library/api/wt/lifecycle/LifeCycleService.html
Below are few method for reassigning lifecycle
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - the container where the objects associated workflow processes will be created
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - the container where the objects associated workflow processes will be created
comments - Notes or comments for the lifecycle operation. Can be null.
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
Parameters:
list - the WTList of LifeCycleManaged objects that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - The container which the object resides in.
state - The state the objects in the lifecycle should be assigned when reassigned to the lifecycle.
Also make sure that end flag will have only one input otherwise workflow process will keep running ( See screenshot ).
Hope this helps !!!
Thanks,
Shreyas
Use wt.lifecycle.LifeCycleHelper.service.reassign(WTDoc, newLFRef);
This will reassign new LC
Regards
Mani.
Hi,
@Igor, thanks but, i don't want to set the state, I want to reassign the LC. meaning all nodes are reset. Currently this can be done via the actions menu on a WTObject that is associated to a LC.
@ Mani, please explain the expression a bit for me. I entered it into an expression robot and I get the following 2 errors. I gather I need to create variable in my WF. What I have is subprocesses running based on the manufacturing plant selected. When the subs are done they leave the pbo in one of two states. Namely; Reopened or Completed. Now, I could't add a task to request a user to perform the reassign action, but I would rather have the system control that for obvious reasins of efficiency. Hence I want to reassign the LC and restart the wf automatically.
From screen shot it seems like you want to restart same workflow process i.e. set the state of POB to open so workflow will be trigger, in that case you can use set state robot to change state to Open (See screen shot)
If you want to reassign any other lifecycle then you can add below line
You can read the documentation related to API from below file
[Windchill_Home]/codebase/wt/clients/library/api/wt/lifecycle/LifeCycleService.html
Below are few method for reassigning lifecycle
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - the container where the objects associated workflow processes will be created
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - the container where the objects associated workflow processes will be created
comments - Notes or comments for the lifecycle operation. Can be null.
Parameters:
object - the LifeCycleManaged object that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
Parameters:
list - the WTList of LifeCycleManaged objects that should be assigned to a new life cycle
lctRef - a reference to a LifeCycleTemplate, the LifeCycleTemplate that the object should be reassigned to
context - The container which the object resides in.
state - The state the objects in the lifecycle should be assigned when reassigned to the lifecycle.
Also make sure that end flag will have only one input otherwise workflow process will keep running ( See screenshot ).
Hope this helps !!!
Thanks,
Shreyas
Hi,
you can use Method Robot and set Robot Type as "Set State" - then select Specific State
Hi Shreyas,
Thanks for your response, There one challenge, when the wf restart the assignee role resolves to wcadmin and not the initial creator of the object. how can I counter this and secondly the conditional connector I have before the last step works for the Reopen route and not the Completed route. What is wrong with my expression? See attached jpeg.
Thanks.
Hi Tshepo,
Write result = "Completed" instead of result="Complete" this values are case sensetive also.
Thanks,
Kaushik
For reassign purpose once I wrote a method (It works for part only you have to modify it )which you can call from workflow with proper inputs.
/**
* Reassigning lifecycle template of the given WTPart object.
*
* @param part
* the WTPart need to be reassigned
*
* @param lifecycleTemplateName
* the LifeCycleTemplate name in which the given WTPart
* will reassign
*
* @exception LifeCycleException
* throws {@link LifeCycleException}
*
* @exception WTException
* throws {@link WTException}
*
* @exception IOException
* throws {@link IOException} by readTGSProperties method if
* the file TGS.properties can't be found
*/
public static void reassignLifeCycle(WTPart part,
String lifecycleTemplateName) throws LifeCycleException,
WTException, IOException {
LOG.debug("The Part :- " + part.getNumber() + " ," + part.getName());
/*
* Getting the LifeCycleTeplateReference from the given Life Cycle
* Template name
*/
final LifeCycleTemplateReference lcRef = LifeCycleHelper.service
.getLifeCycleTemplateReference("name of the LC", part
.getContainerReference());
LOG.debug("The Life Cycle Template Name :- " + lifecycleTemplateName);
if (lcRef == null) {
throw new WTException("Life Cycle Not Found");
} else if (WorkInProgressHelper.isCheckedOut((Workable) lcRef
.getObject())) {
throw new WTException("Life Cycle Template is checked out");
}
// Reassigning the lifecycle with the given value
final LifeCycleManaged lcm = LifeCycleHelper.service.reassign(
(LifeCycleManaged) part, lcRef, part.getContainerReference());
// Set the state of the life cycle to the specific state
/* if (stateName != null) {
LifeCycleHelper.service.setLifeCycleState(lcm,
State.toState(stateName));
} */
LOG.info("Reassigning Complete");
// Refreshing WTPart after reassigning the life cycle and setting the
// state
PersistenceHelper.manager.refresh(lcm);
}
Thanks,
Kaushik
Hey Kaushik,
Thanks I picked that up last Thursday. I felt a bit stupid that I had missed the "d". Thanks anyways for the trouble of answering.
Hi Shreyas, The wf works, thanks a lot. Can you assist with how I get the role of the assignee of wf tasks to be reverted to the original assignee, who was the creator of the object.
looks like first activity is your workflow is assigned to Creator-Actor.
you can assign first activity to any role instead of Creator-Actor. i.e. you can assign this activity to Owner role then you need to add creator of object into owner role
this can achieve this using two way 1. using lifecycle 2. Team template without writing code
Edit the lifecycle > go the first state > Role >add Owner Role >participants > Actors > add Creator .save and check in the lifecylce
Add owner role in team template and creator actor in owner role
Hope this helps !!!
Thanks,
shreyas