Page 1 of 1

[SOLVED] route last task

Posted: Wed Apr 06, 2016 7:28 am
by awisla
Hello,
I'd like to route last task with current user logged:
I have following code from wiki:
-----------------------------
$caseId = @@APPLICATION;
//lookup the user assigned to the next task in the case
$query = "SELECT AD.DEL_INDEX, U.USR_USERNAME
FROM APP_DELEGATION AD, USERS U
WHERE AD.APP_UID='$caseId' AND
AD.DEL_INDEX=(SELECT MAX(DEL_INDEX) FROM APP_DELEGATION WHERE APP_UID='$caseId')
AND AD.USR_UID=U.USR_UID";
$result = executeQuery($query);
$nextUser = $result[1]['USR_USERNAME'];
$nextIndex = $result[1]['DEL_INDEX'];

//lookup the md5 hash for the password
$result = executeQuery("SELECT USR_PASSWORD FROM USERS WHERE USR_USERNAME='$nextUser'", 'rbac');
$nextPass = 'md5:' . $result[1]['USR_PASSWORD'];

$client = new SoapClient('http://192.168.1.76:2036/sysworkflow/en ... ices/wsdl2');
$params = array(array('userid' => $nextUser, 'password' => $nextPass));
$result = $client->__SoapCall('login', $params);

if ($result->status_code == 0)
$sessionId = $result->message;
else
die("Unable to connect to ProcessMaker.\nError Message: {$result->message}");

$params = array(array(
'sessionId'=> $sessionId,
'caseId' => @@APPLICATION,
'delIndex' => $nextIndex
));
$result = $client->__SoapCall('routeCase', $params);
if ($result->status_code != 0)
die("Error routing case: {$result->message}\n");
-----------------------------------


Code works fine, but when I want to route last task in process ( Rejected, Approved ), then the status does not change to completed.
Could you please advise what parameter should be updated in order to get process completed.

Thank you for help
Adrian

Re: route last task

Posted: Wed Apr 06, 2016 1:45 pm
by ethanpresberg
That is not the correct way to design the process. What you are doing is essentially saying, if the manager approves it, send the case to a task called "Approved" or if he rejects it, send it to a task called "Rejected".

What you want to do is send the process through to an end event, like you have for finished. So, in your case, I would eliminate the gateway and 2 tasks, and simply connect the Manager Approval task to the Finished end event. If you want to know if the workflow is approved/rejected, just look at the variable you are saving that status in.

Re: route last task

Posted: Fri Apr 08, 2016 8:38 am
by awisla
Hello,
Thank you for clarification.

Regards
Adrian