Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#823398
Hello, i was wondering what the best way would be to route a case with a CRON job? It would run it once a day to see if todays date met a certain deadline. If it did, we would route the case to the next step which would be to complete it. Let me know if anyone has an ideas. Thanks.
#823405
You can create a custom script that uses web services or REST to route cases based on a criteria, which is executed by a cron job, but I recommend that you create a separate process which loops to execute a script task and uses an intermediate timer event.

The basic idea is explained here:
https://www.pmusers.com/index.php/Send_ ... is_overdue

Instead of sending a message with PMFSendMessage() in the trigger, you can call PMFDerivateCase() to route on the case.

Here is the trigger that you can use in the script task:
Code: Select all
//set to the ID of the task which should send an email when overdue.
//this ID can be found by running a case in Debug Mode and looking at the TASK system variable:
$taskId = '3839855285b99bcad876958079357667';

//Search for cases where the task is overdue:
$now = date("Y-m-d H:i:s");
$query= "SELECT * FROM APP_CACHE_VIEW WHERE TAS_UID='$taskId' AND
  (APP_STATUS='TO_DO' OR APP_STATUS='DRAFT') AND DEL_THREAD_STATUS='OPEN' AND '$now' > DEL_TASK_DUE_DATE";

$aCases = executeQuery($query);

if (!is_array($aCases)) {
  die("Error: Bad Query: $query\n");
}
$g = new G();
$g->sessionVarSave();

foreach ($aCases as $aCase) {
   PMFDerivateCase($aCase['APP_UID'], $aCase['DEL_INDEX'], false, $aCase['USR_UID']);  
}
$g->sessionVarRestore();
 
You can change the code of your SQL query. If you only want to execute on particular dates, then you should check out PHP's PHP's date() function to make a condition that you can check in the code.

In the rapidly evolving world of online sports be[…]

STEPN integrates social networking and games that […]

Cenforce 150 is a medication used to cope with a c[…]

What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]