I need assistance creating a code for a conditional node that will check to make sure the task has been complete. The task for this particular node is that the user creates a service request within windchill. How I see this working would be the system would look at the PBO of the workflow and grab the value in the attribute called "Serial #" and add it to a variable in the workflow. Then the system can search for a service request document and see if there is one out there at also has a serial # that matches. If yes then it allows the workflow to move on, if no it sends another task back to the user to create the document and will stay in the loop until he or she does.
Below is a sample of code we already have that does this exact thing, but for Managed Collections (matches names and adds PBO to MC automatically).
wt.facade.persistedcollection.ManagedCollection mc = null;
java.lang.String collectionName = ((wt.doc.WTDocument)primaryBusinessObject).getName().toUpperCase();
wt.query.QuerySpec qs = new
wt.query.QuerySpec(wt.facade.persistedcollection.ManagedCollection.class);
qs.appendWhere(new wt.query.SearchCondition(wt.facade.persistedcollection.ManagedCollection.class, wt.facade.persistedcollection.ManagedCollection.NAME, wt.query.SearchCondition.EQUAL, collectionName), new int[] { 0 });
wt.fc.QueryResult qr = wt.fc.PersistenceHelper.manager.find((wt.pds.StatementSpec) qs);
if (qr.hasMoreElements()) {
mc = (wt.facade.persistedcollection.ManagedCollection) qr.nextElement();
System.out.println("\n\n\t\t Found Managed Collection!");
} else {
System.out.println("Unable to find ManagedCollection with name \"" + collectionName + "\"");
//save the MC name in a global variable so that we can use it in the activity that we will be sending to the admin to ask for creating the MC
MCName=collectionName;
result="MCNOTFound";
}
if (mc != null)
{
mc = (wt.facade.persistedcollection.ManagedCollection) wt.facade.persistedcollection.PersistedCollectionHelper.service.checkout(mc);
wt.facade.persistedcollection.PersistedCollectionHelper.service.addSeed(mc, (wt.doc.WTDocument)primaryBusinessObject);
//wt.facade.persistedcollection.PersistedCollectionHelper.service.addMember(mc, (wt.doc.WTDocument)primaryBusinessObject);
wt.facade.persistedcollection.PersistedCollectionRecipe recipe = wt.facade.persistedcollection.PersistedCollectionHelper.service.getRecipe(mc);
if (recipe == null) {
recipe = wt.facade.persistedcollection.PersistedCollectionRecipe.newPersistedCollectionRecipe();
wt.facade.persistedcollection.PersistedCollectionHelper.service.setRecipe(mc, recipe);
}
mc = (wt.facade.persistedcollection.ManagedCollection) wt.facade.persistedcollection.PersistedCollectionHelper.service.refreshMembers(mc, "AddToManagedCollection");
mc = (wt.facade.persistedcollection.ManagedCollection) wt.facade.persistedcollection.PersistedCollectionHelper.service.checkin(mc);
result="AddedToMC";
}
I don't need to add the PBO to anything, just need to make sure users are actually completing their task before they "complete task" in the UI.
Any assistance or ideas would be greatly appreciated....also, I am not a code guy at all.
Greg