Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By Sighto
#791828
Is there a clean way to route a case back to the first task if a Reject button is hit without using a gateway for each task the form can get rejected at? This would mean 14 additional gateways for this process. I'd also like to re-purpose ProcessMaker's built-in Cancel Case popup window into a Reject Case popup to update the case notes if possible.
Cancel Case.png
Cancel Case.png (7.5 KiB) Viewed 2841 times
User avatar
By amosbatto
#791835
Unfortunately, ProcessMaker doesn't provide a way to return to the first task in a case without having a route in your process to return to the first task.

You could cancel the existing case with PMFCancelCase() and create a new case with the PMFNewCase() function in a trigger that and pass the existing variables from the old case to the new case. That is probably the best option. You probably want to set a case label in the new case to indicate something like: "#69 Restarted #56"

Another option is to simply delete all the records for the case in the APP_CACHE_VIEW and APP_DELEGATION tables in the database except the records where the DEL_INDEX=1. Here is the trigger code:
Code: Select all
$caseId = @@APPLICATION;
$sql = "DELETE FROM APP_CACHE_VIEW WHERE APP_UID='$caseId' AND DEL_INDEX<>1";
executeQuery($sql);  
$sql = "DELETE FROM APP_DELEGATION WHERE APP_UID='$caseId' AND DEL_INDEX<>1";
executeQuery($sql);  
$dueDate = date('Y-m-d H:i:s', strtotime('+1 day'));
$riskDate = date('Y-m-d H:i:s', strtotime('+22 hours'));
$sql = "UPDATE APP_CACHE_VIEW SET DEL_THREAD_STATUS='OPEN', DEL_FINISH_DATE=NULL, 
   DEL_RISK_DATE='$riskDate', DEL_TASK_DUE_DATE='$dueDate' WHERE APP_UID='$caseId' AND DEL_INDEX=1";
executeQuery($sql);  
$sql = "UPDATE APP_DELEGATION SET DEL_THREAD_STATUS='OPEN', DEL_FINISH_DATE=NULL, 
   DEL_RISK_DATE='$riskDate', DEL_TASK_DUE_DATE='$dueDate', APP_STATUS='TO_DO' WHERE APP_UID='$caseId' AND DEL_INDEX=1";
executeQuery($sql);
$sql = "UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='$caseId' ";
executeQuery($sql);

This is definitely not the recommended option, since it will leave orphaned records in APP_HISTORY, APP_DOCUMENT, etc. which refer to tasks that don't exist in the database and I haven't tested it, so use it at your own risk.

As for altering the cancel case dialog box, you can alter the cancelCase() function defined on line 896 in workflow/engine/templates/cases/open.js
and you can alter the cancelCase() function defined on line 533 in workflow/engine/methods/cases/ajaxListener.php

Good luck.

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]