Complete Task Transition
Many activities are routed based on
vote tallies. For example, an approval task might be assigned to several users. To complete the task, the user must either approve or reject the object under review. The option they select determines how the workflow progresses.
Vote tallies are typically configured by adding an expression under the
Routing tab. However, you can use the
Complete Task transition under the
Transitions tab for more detailed control over the tallying process.
Example
You create a simple workflow template to use when reviewing certain objects. The first activity requires users to review the object and approve or reject it.
If the object is approved, it moves to the Approved state. If it is rejected, it moves to the Rejected state:
All participants are required. The activity participants are users in the Quality Manager role and the Engineer role:
• To move the object to the Approved state, all participants must vote “Approve.”
• If any 2 users in the Quality Manager role vote “Reject,” the activity is completed and the object is moved to the Rejected state.
To accomplish this, you can enter the following expression for the Complete Task transition:
java.util.Locale locale=wt.util.WTContext.getContext().getLocale();
int number=wt.workflow.work.WfTally.count(self,"Reject","Quality Manager",locale);
if(number>=2)
{
wt.workflow.work.WorkflowHelper.service.completeActivity(self,"Reject");
}
Complete Task API
Tally votes by role:
/* * @param self : WfAssignedActivity ObjectReference * @param eventToMatch : Routing option to tally * @param assigneeRole : Role for which you want to tally the routing option * @param locale : The locale in which you have specified the assignee role * @return int : Number of votes from user in the specified role * @throws WTException */
public static int count(ObjectReference self,String eventToMatch,String assigneeRole,Locale locale) throws WTException
|
Tally votes by routing event:
/* * @param self : WfAssignedActivity ObjectReference * @param eventToMatch : Routing option to tally * @param int : Number of votes for the routing event in the activity * @throws WTException */
public static int count(ObjectReference self,String eventToMatch) throws WTException
|
Complete activity when conditions are met:
/* Supported API : True Method to complete the activity * @param self : WfAssignedActivity ObjectReference * @param events : Routing event to follow * @throws WTException */
public void completeActivity(ObjectReference self,String events) throws WTException
|