Routing on other parallel task and loop back

From pmusers
Jump to: navigation, search

This example shows how to route on another parallel task based on the decision of a manager.


Process: Route_on_other_parallel_task_if_rejected-1.pmx (right click and select Save Link As)


Create the following process to approve or reject the request for a new resource:

RouteOtherParallel ProcessMap.png

Then, add the following routing rule conditions in the exclusive gate:

RouteOtherParallel RoutingRules.png

Next, add the following trigger:

if (@@decision == 'rejected') {
	//set to title of other parallel task:
	$otherParallelTask = 'Do logistics';
	
	$opTaskId = PMFGetTaskUID($otherParallelTask);
	
	if (empty($opTaskId)) {
		throw new Exception("Task '$otherParallelTask' not found!");
	}
	
	//look up other parallel task's delegation index in the database:
	$caseId = @@APPLICATION;
	$sql = "SELECT * FROM APP_CACHE_VIEW WHERE APP_UID='$caseId' AND 
		TAS_UID='$opTaskId' AND DEL_THREAD_STATUS='OPEN' ORDER BY DEL_INDEX DESC";
	$aTasks = executeQuery($sql);
	@@ATasks = $aTasks;
	
	//if another open parallel task is found, then route it on:
	if (!empty($aTasks)) {
		$g = new G();
        $g->sessionVarSave();
		@@ret = PMFDerivateCase($caseId, $aTasks[1]['DEL_INDEX'], false, $aTasks[1]['USR_UID']);
		$g->sessionVarRestore();
	}
}

Set this trigger to fire before assignment in the "Approve Request" task.


RouteOtherParallelTask RequestResource.png

RouteOtherParallelTask RejectedDecision.png

RouteOtherParallel RouteBackToFirstTask.png