Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Translate the entire conversation x

workflow Check-In

vmcdaniel
12-Amethyst

workflow Check-In

Is it possible to force the check-in of the PBO's in a workflow? I tried the Method Robot, but it just hangs on it.
That or, I want to re-assign the task to participant.
I've searched the customization guides, where else can I look to find this info?
12 REPLIES 12

You have to use the API in a robot or activity transition to make sure you
do it right. Just look in the javadoc for the helper to help with these
methods.

Al







[solutions] - workflow Check-In

Vaughn McDaniel

Hi Vaughn,



My suggestion is that you add an expression into the "Complete"
transition of the task.



In the example below, the expression checks if the object is checked out
when the user attempts to complete the task. If the object is checked
out, the user is presented with the error defined in the "new Exception"
statement and the task does not complete. If the object is checked in,
the task completes and the process moves forward.







Expression



//Check the Primary Business Object
java.lang.Exception pe = null;
pe = new Exception("The object is checked out. Please check it back in
before completing your task.");
boolean pisCheckedOut =
wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable)primaryB
usinessObject);
if (pisCheckedOut)
{
throw new wt.workflow.engine.FailedTransitionException ( pe );
}



Hope this helps,

Dax


DAX,

This is exactly what I was looking for, thanks!

-Vaughn
pwilliams-3
13-Aquamarine
(To:vmcdaniel)

Vaughn,
In 10.1 M010 you can use the new Business Rules engine which has a "Checked Out" rule.

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image002.jpg@01CD64BF.B63F1110]

Vaughn,


Yes, this is doable.


Are you checking to make sure the object is actually checked out prior to attempting check it.


I almost never use method robots because they don't check if what you want to do can be done prior to attempting to do it.


try this code in an expression robot


if (primaryBusinessObject.getObject() instanceof wt.vc.wip.Workable && wt.vc.wip.WorkInProgressHelper.isCheckedOut(primaryBusinessObject.getObject())) { //Check if the object is checked out


wt.vc.wip.WorkInProgressHelper.service.checkin(primaryBusinessObject.getObject(), null); //Check it in


}


Hope thie helps

DAX, or anyone else.


Have you used the same code in CN Task wf as well as the Promotion Request?

In Reply to Vaughn McDaniel:


DAX,

This is exactly what I was looking for, thanks!

-Vaughn

Yay! I did it!



Here is the Change Task version:




ensure all objects are checked in before completing your task.");


throw new wt.workflow.engine.FailedTransitionException ( pe );


}


}




Vaughn,
I did almost the exact same thing in our promotion request processes in the rework task with the following code. It works for all object types (EPMDocument, WTPart, WTDocument).

java.lang.Exception pe = null;
pe = new Exception("There are objects on " + prNumber + " that are checked out.\nPlease check them in before completing your task.");
wt.fc.QueryResult queryresult = wt.maturity.MaturityHelper.service.getPromotionTargets((wt.maturity.PromotionNotice) primaryBusinessObject);
while (queryresult.hasMoreElements()) {
wt.fc.WTObject obj = (wt.fc.WTObject) queryresult.nextElement();
boolean coSw = wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable) obj);
if (coSw) throw new wt.workflow.engine.FailedTransitionException(pe);
}

Mike

Boo, I didn't do it! 😞



At runtime this throws an error.



Does anyone know if this part of the code is even applicable to the Change Activity?


wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable)obj);



If not what isa correlating check a CA needs?



Thanks!

In Reply to Vaughn McDaniel:



Yay! I did it!



Here is the Change Task version:




ensure all objects are checked in before completing your task.");


throw new wt.workflow.engine.FailedTransitionException ( pe );


}


}





Vaughn,
Try this code in a Change Activity transition or loop robot.

/*
Check the objects on a Change Activity to see if any of them are checked out.
*/
java.lang.Exception pe = null;
boolean coSw = false;
pe = new Exception("There are objects on Change Activity that are checked out.\nPlease check them in before completing your task.");
wt.fc.QueryResult queryresult = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.ChangeActivity2)primaryBusinessObject);
while (queryresult.hasMoreElements()) {
wt.fc.WTObject obj = (wt.fc.WTObject) queryresult.nextElement();
coSw = wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable) obj);
if (coSw) throw new wt.workflow.engine.FailedTransitionException(pe);
}

Mike

No luck, same error after clicking 'Complete task', this is with Orgadmin

---error---
ATTENTION:
This task cannot be displayed because you do not have permission to
view the subject. Contact your project manager to increase your access
rights.
---error---


[cid:image001.png@01CE8D24.AB837020]

-Vaughn
720-216-3495
PLM?<">http://en.wikipedia.org/wiki/Product_lifecycle_management> Windchill?<">http://www.ptc.com/WCMS/files/130891/en/flash/index.htm?&im_dbkey=130891&im_language=en> PLM for SMB?<">http://www.ptc.com/WCMS/files/129410/en/flash/index.htm?&im_dbkey=129410&icg_dbkey=362>

Vaughn,
If you take all of the code out of that task, does the task complete correctly and move on to the next step in the workflow?

Mike Ibosh
Announcements

Top Tags