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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

workflow help

RajeshBalasunda
2-Explorer

workflow help


Hi, I need some help in setting up a parallel task. Two tasks are fired based on arouting. One will be a activity task and the other will be a timer. What I want to achieve is, if the user completes the activity before the timer, the timer task needs to be terminated and vice-versa.How can this be achieved. Any help on getting this setup is greatly appreciated.



Regards,

Rajesh Balasundaram

6 REPLIES 6

Activities essentially have timers built into them (the Deadline tab). When the Deadline is reached, a variety of things can be done.

Create a connection between the two parallel tasks. When one completes,
it should terminate the other and visa versa. You might stick an OR
connection in between to pretty up the workflow since the links will be
on top of each other. Make sense?




When the task completes, you want to wire up a connection between the task and the timer to send a Terminate to the timer.

if there are multiple routings, then each one would be set to send a terminate to that timer

All,

Currently when using Windchill API for creating a part and BOM at the same time it is a 2 step process. First we create the part and store it, then if we want to modify the BOM we have to c/o the part and add the Part usage link. Creating the part will result in A.1 and updating the part usage link will result in A.2. Does anyone know a way to create the part and the usage link at the same time resulting in A.1 version?

Here is a sample version of the code:

import java.util.Vector;
import wt.part.*;
import wt.fc.PersistenceHelper;
import wt.folder.FolderHelper;
import wt.folder.Folder;
import wt.occurrence.*;
import wt.part.Quantity;
import wt.part.WTPartUsageLink;
import wt.part.PartUsesOccurrence;
import wt.occurrence.OccurrenceHelper;

public class OccurrenceExample
{
public static void main(String args[])
{
try {
// Get location for both parts
Folder location=FolderHelper.service.getFolder("/Parts");

// Create and persist wagon
WTPart wagon=WTPart.newWTPart("WAGON123","WAGON123");
FolderHelper.assignLocation(wagon,location);
wagon=(WTPart)PersistenceHelper.manager.save(wagon);

// Create and persist wheel
WTPart wheel=WTPart.newWTPart("WHEEL123","WHEEL123");
FolderHelper.assignLocation(wheel,location);
wheel=(WTPart)PersistenceHelper.manager.save(wheel);

// Checkout wagon
wagon=(WTPart)wt.vc.wip.WorkInProgressHelper.service.checkout(wagon,wt.vc.wip.WorkInProgressHelper.service.getCheckoutFolder(),(String) null).getWorkingCopy();

// Get Quantity for wheels
Quantity quantity=Quantity.newQuantity(4,wt.part.QuantityUnit.EA);

// Create UsageLink, set quantity and persist
WTPartUsageLink wtpu=WTPartUsageLink.newWTPartUsageLink(wagon,(WTPartMaster) wheel.getMaster());
wtpu.setQuantity(quantity);
wtpu=(WTPartUsageLink) PersistenceHelper.manager.save(wtpu);
// Check wagon back in
wagon=(WTPart)wt.vc.wip.WorkInProgressHelper.service.checkin(wagon,(String) null);

// Create FR, FL, BR, BL occurrences and persist them
PartUsesOccurrence fr=PartUsesOccurrence.newPartUsesOccurrence(wtpu);
fr.setName("Front Right");
OccurrenceHelper.service.saveUsesOccurrenceAndData(fr, (Vector) null);

PartUsesOccurrence fl=PartUsesOccurrence.newPartUsesOccurrence(wtpu);
fl.setName("Front Left");
OccurrenceHelper.service.saveUsesOccurrenceAndData(fl, (Vector) null);

PartUsesOccurrence br=PartUsesOccurrence.newPartUsesOccurrence(wtpu);
br.setName("Back Right");
OccurrenceHelper.service.saveUsesOccurrenceAndData(br, (Vector) null);

PartUsesOccurrence bl=PartUsesOccurrence.newPartUsesOccurrence(wtpu);
bl.setName("Back Left");
OccurrenceHelper.service.saveUsesOccurrenceAndData(bl, (Vector) null);
System.exit(0);

} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}






If you want to preserve BOM to specific iterations, you'll have to get more
complicated than the code you provided. These helper API's will not shake
it for you, they are still too high level. Many places do not care about
the iteration as much as they do the revision.



You will need to dig into creating a part, not persisting it right away,
fiddling with version identifier objects and then building the usage link.
This is how the import from spreadsheet works as the part and links didn't
exist in db beforehand.



Your other option is changing the version identifier on it after it is done
creating the link. If you go this way, avoid VersionControlHelper API as it
is too high level also.



If you are on 9.1, my gut says to try this:



- Delete the first iteration

- Update any other references to deleted iteration

- Change version identifier on A.2 back to A.1



Versioned versioned =
com.ptc.windchill.cadx.common.util.GenericUtilities.setVersionIdentifierForO
bject(Versioned object, "A.1");



-or-

Versioned versioned =
com.ptc.windchill.cadx.common.util.GenericUtilities.setVersionIdentifierForO
bject(Versioned object, VersionIdentifier identifier, boolean
someboolvalue);





If I were doing this though, I'd reverse engineer the import from
spreadsheet logic to see what it invokes and pass my name/number/quantity
that way. I also look at why it needs to be checked out in the
WTPartUsageLink.newWTPartUsageLink method or what it invokes and see if you
can bypass that requirement because this is used by the UI, so it naturally
wants to check it out.



Hope this helps,

Dave




I've achieved this before using a pretty simple method:

Connect both your timer task and your user task to a single "OR" logic node and make sure in that node to select the "Terminate Open Predecessor Activities When Fired" checkbox. Then, from your "OR" node build the rest of the workflow. This will build two outcomes:

1. User finishes task before timer: the "OR" node gets fired and "kills" the timer task.

2. Timer finishes before user task: the "OR" node gets fired and "kills" the user task.

Announcements


Top Tags