Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

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 marcosfpa
#793588
Hello.
The ProcessMaker Community does not have Timer Edge event, which is timed task control and perform an action when the deadline expires. I have a need that is to derive the case to another task when the current task expires the deadline. Is this possible via TRIGGER or some function?
User avatar
By amosbatto
#793595
Create a separate loop-around process that periodically executes a trigger which routes on cases in the other process that have spent too long in the task:
looparoundprocess.png
looparoundprocess.png (10.88 KiB) Viewed 1902 times
Set the intermediate timer event to execute every couple hours.

In the script task, use this trigger:
Code: Select all
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXX'; //Set to the ID of the task to skip in the other process
$now = date('Y-m-d H:i:s');
$query= "SELECT AD.*, U.USR_USERNAME 
   FROM APP_DELEGATION AD, USERS U
   WHERE AD.DEL_THREAD_STATUS='OPEN' AND AD.TAS_UID = '$taskId' AND 
   DEL_TASK_DUE_DATE < '$now' AND AD.USR_UID=U.USR_UID";
$aDelegations = executeQuery($query);

if (!is_array($aDelegations)) {
   throw new Exception("Error: Bad Query: ".$query);
}
$g = new G();
$g->sessionVarSave();

foreach ($aDelegations as $aDel) {    
   $result = PMFDerivateCase($aDel['APP_UID'], $aDel['DEL_INDEX'], false, $aDel['USR_UID']);
   if (is_object($result)) {
      throw new Exception('Error routing case: '.$result->message);
   }   
} 
$g->sessionVarRestore();
Set up your server to periodically execute the timereventcron.php script. Then start a new case in your loop-around case and route it to the second task so it will run forever.
User avatar
By amosbatto
#793633
To debug, execute the trigger in a normal task and check the @@__ERROR__ variable in the debugger.
Try this code to debug:
Code: Select all
@=aDelegations = $aDelegations;
foreach ($aDelegations as $aDel) {   
   $result = PMFDerivateCase($aDel['APP_UID'], $aDel['DEL_INDEX'], false, $aDel['USR_UID']);
   @=result = $result;
   if (is_object($result)) {
      throw new Exception('Error routing case: '.$result->message);
   }   
} 
User avatar
By amosbatto
#793797
Oh I see the problem in the code I gave you. Change this line:
Code: Select all
if (!is_array($row)) {
   throw new Exception("Error: Bad Query: ".$query);
}
To:
Code: Select all
if (!is_array($aDelegations)) {
   throw new Exception("Error: Bad Query: ".$query);
}
I have corrected it in the original post.

I have a suggest where user have to select some do[…]

The 500 Internal Server Error is the general catch[…]

Really very nice blog information for this one and[…]

This is a long, lengthy and cumbersome process. T[…]