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

Reassign Life cycles within a workflow

SOLVED
Highlighted

Reassign Life cycles within a workflow

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.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Reassign Life cycles within a workflow

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)

screen1.jpg

If you want to reassign any other lifecycle then you can add below line

  1. wt.lifecycle.LifeCycleHelper.service.reassign(primaryBusinessObject, LifeCycleHelper.service.getLifeCycleTemplateReference(" UR LIFECYCLE Name "));

screen2.jpg

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

  1. 1. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef, WTContainerRef context) throws WTException, LifeCycleException

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

  1. 2. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef, WTContainerRef context, String comments) throws WTException, LifeCycleException

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.

  1. 3. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef) throws WTException, LifeCycleException

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

  1. 4. reassign(WTList list, wt.lifecycle.LifeCycleTemplateReference lctRef, WTContainerRef context, State state)

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

View solution in original post

10 REPLIES 10

Re: Reassign Life cycles within a workflow

Hi,

you can use Method Robot and set Robot Type as "Set State" - then select Specific State

wf_editor.png

iviewcapture_date_28_10_2013_time_11_18_58.png

Re: Reassign Life cycles within a workflow

Use wt.lifecycle.LifeCycleHelper.service.reassign(WTDoc, newLFRef);

This will reassign new LC

Regards

Mani.


Re: Reassign Life cycles within a workflow

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.

Re: Reassign Life cycles within a workflow

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)

screen1.jpg

If you want to reassign any other lifecycle then you can add below line

  1. wt.lifecycle.LifeCycleHelper.service.reassign(primaryBusinessObject, LifeCycleHelper.service.getLifeCycleTemplateReference(" UR LIFECYCLE Name "));

screen2.jpg

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

  1. 1. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef, WTContainerRef context) throws WTException, LifeCycleException

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

  1. 2. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef, WTContainerRef context, String comments) throws WTException, LifeCycleException

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.

  1. 3. LifeCycleManaged reassign(LifeCycleManaged object, LifeCycleTemplateReference lctRef) throws WTException, LifeCycleException

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

  1. 4. reassign(WTList list, wt.lifecycle.LifeCycleTemplateReference lctRef, WTContainerRef context, State state)

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

View solution in original post

Re: Reassign Life cycles within a workflow

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.

Re: Reassign Life cycles within a workflow

Hi Tshepo,

Write result = "Completed" instead of result="Complete" this values are case sensetive also.

Thanks,

Kaushik

Re: Reassign Life cycles within a workflow

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

Re: Reassign Life cycles within a workflow

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.

Re: Reassign Life cycles within a workflow

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.

Announcements
LiveWorx Call For Papers Happening Now!