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 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 6794 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.
By RobertoB
#828978
Dear Amos,

Thank you for all the hints.

Can this be done with a loop-around task in the same process? And can the the overdue task be a user task with a dynaform?

The issues is: how to make a user task with dynaform not wait forever, so that it proceeds to the loop-around task.

I suppose that PMFDerivateCase() would work also within the same process.

Best regards,

Roberto
By RobertoB
#828979
well, I guess I know the answer from your other post:
https://forum.processmaker.com/viewtopic.php?f=44&t=730695&p=815024&hilit=task+timer+trigger#p815024

"[...]If you include a intermediate Timer Event in your process, then the flow of the process will stop until the timer finishes (and the timereventcron.php script is executed to resume the case). "

Since Boundary Interrupt Timers are not part of PM Community, I guess the only option is a separate process running infinitely. Correct?

Roberto

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[…]

Betvisa clone scripts are pre-built software solut[…]

A Bet365 Clone Script is essentially a ready-made […]