Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By processmaker
#786804
Hi! I need some help in executing a task in processmaker in which i've been stuck since many days. Here goes the description:
I have made an expense claim form where any person who initiates the claim has to go through his/her respective supervisor's approval until the final task of approval by the head boss. Anyway, the problem that I have is with the escalation where I am supposed to escalate the task by sending an email to the respective supervisor after a set time (e.g 24 hrs) to remind that person. I have looked for similar queries but have only found one related to triggers which I couldn't understand. If a trigger is to be used then could you kindly explain it step wise?
By rcgongora
#786811
Hi Processmaker User:

Have you consider using a Intermediate Timer event before a task that contains the trigger "PMF Send Message"? It would be a great help in order to wait a given time before the sending mail task. Something like the attached image.

Please let us know, if you have some problem setting up the intermediate event.

Best Regards.
Roberto Góngora
Software Quality Engineer
ProcessMaker
Attachments
testing.png
testing.png (60.97 KiB) Viewed 7415 times
User avatar
By amosbatto
#786813
You could use an Intermediate Event Timer, but that stops the process while waiting for the timer. The most elegant solution is to write an external script which consults the database for open cases at that task and checks whether 24 hours has elapsed. If so, it then calls the executeTrigger() web services to execute a trigger which has code to calls PMFSendMessage().

A less elegant but easier solution is for you to create a separate process that looks like this:
LooparoundProcess.png
LooparoundProcess.png (10.86 KiB) Viewed 7413 times
Set the Intermediate Timer Event to execute after 6 hours. Then set the second task to be a script task and its properties, add this trigger code:
Code: Select all
$processId = '616783822574cf2978e4021022999229'; //set to process where overdue tasks 
$taskId    = '765123173574cf41b505353098774041'; //set to ID of task to check if it is overdue
$currentDate = date('Y-m-d H:i:s');
$sql = "SELECT * FROM APP_DELEGATION WHERE PRO_UID='$processId' AND TAS_UID='$taskId' 
  AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '$currentDate' ";
$aCases = executeQuery($sql) or die("Error in query: $sql");

foreach ($aCases as $aCase) {
   $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
   $aUserInfo = userInfo($aCase['USR_UID']);
   $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
    
   $c = new Cases(); 
   PMFSendMessage($aCase['APP_UID'], $from, $to, '', '', 
      "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array()); 
}
 
Also create your template file "overdue.html". (You can pass variables to the template if you need to through the array in PMFSendMessage(). )

Then, assign your "admin" to the "dummy task" in the process and run a case in this process so you complete the "dummy task" and route to the script task to test it.

Then, set up your server to periodically execute the timereventcron.php file.
By processmaker
#786818
[quote="rcgongora"]

"Have you consider using a Intermediate Timer event before a task that contains the trigger "PMF Send Message"? It would be a great help in order to wait a given time before the sending mail task. Something like the attached image."

Thank you for your reply.
I tried this method but I'm facing a few problems:
1)In the PMFsend Message trigger, what should I type in the Case UID and ReturnValue?
2) I have executed the cron script as well and set the intermediate event timer to 3 minutes but I'm neither getting the email nor am is the case going to the last task of PMFSendMessage. What could be the problem in your opinion?
By processmaker
#786819
amosbatto wrote:You could use an Intermediate Event Timer, but that stops the process while waiting for the timer. The most elegant solution is to write an external script which consults the database for open cases at that task and checks whether 24 hours has elapsed. If so, it then calls the executeTrigger() web services to execute a trigger which has code to calls PMFSendMessage().

A less elegant but easier solution is for you to create a separate process that looks like this:
LooparoundProcess.png
Set the Intermediate Timer Event to execute after 6 hours. Then set the second task to be a script task and its properties, add this trigger code:
Code: Select all
$processId = '616783822574cf2978e4021022999229'; //set to process where overdue tasks 
$taskId    = '765123173574cf41b505353098774041'; //set to ID of task to check if it is overdue
$currentDate = date('Y-m-d H:i:s');
$sql = "SELECT * FROM APP_DELEGATION WHERE PRO_UID='$processId' AND TAS_UID='$taskId' 
  AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '$currentDate' ";
$aCases = executeQuery($sql) or die("Error in query: $sql");

foreach ($aCases as $aCase) {
   $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
   $aUserInfo = userInfo($aCase['USR_UID']);
   $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
	
   $c = new Cases(); 
   PMFSendMessage($aCase['APP_UID'], $from, $to, '', '', 
      "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array()); 
}
Also create your template file "overdue.html". (You can pass variables to the template if you need to through the array in PMFSendMessage(). )

Then, assign your "admin" to the "dummy task" in the process and run a case in this process so you complete the "dummy task" and route to the script task to test it.

Then, set up your server to periodically execute the timereventcron.php file.

Thanks a lot for your reply!
I started with the easy solution that proposed and I'm getting this error message:
Error in query: SELECT * FROM APP_DELEGATION WHERE PRO_UID='616783822574cf2978e4021022999229' AND TAS_UID='765123173574cf41b505353098774041' AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '2016-09-30 14:15:18'


I assigned the dummy task to admin and made an empty overdue.html template file. Also, I added your code to the script task.
For the cron execution I simply ran the location of cron.php in my cmd and it was executed. Please can you tell me what I'm doing wrong which is resulting in the aforementioned error? Thanks!
User avatar
By amosbatto
#786823
If you got that error message, then you didn't change the process ID and task ID in the trigger code to match your process.

Also, you might need to set the task duration to 1 day in the task properties if you changed it from the default setting.
By processmaker
#787187
amosbatto wrote:If you got that error message, then you didn't change the process ID and task ID in the trigger code to match your process.

Also, you might need to set the task duration to 1 day in the task properties if you changed it from the default setting.
I used the trigger ID as the case ID but I don't know how to find the process ID. Kindly tell me how to look both these IDs up
By michaeltimoteo
#787188
When you open the the debug mode and see the variable "PROCESS" that is the process UID. The task UID is almost the same with the variable "TASK"
By processmaker
#787189
michaeltimoteo wrote:When you open the the debug mode and see the variable "PROCESS" that is the process UID. The task UID is almost the same with the variable "TASK"
How do I open the debug mode? Is the task ID also shown in the debug mode?
Thanks!
By michaeltimoteo
#787190
Hi

Please refer to the screenshot below:
designer.PNG
designer.PNG (86.56 KiB) Viewed 7366 times
debug.PNG
debug.PNG (99.86 KiB) Viewed 7366 times
I hope this solves your PRO_UID and TAS_UID issue.
By processmaker
#787191
michaeltimoteo wrote:Hi

Please refer to the screenshot below:
designer.PNG
debug.PNG
I hope this solves your PRO_UID and TAS_UID issue.
Thank you very much! I found them right away with the help of those screenshots
By processmaker
#787192
amosbatto wrote:If you got that error message, then you didn't change the process ID and task ID in the trigger code to match your process.

Also, you might need to set the task duration to 1 day in the task properties if you changed it from the default setting.
I have made all the changes that you suggested but I'm still getting the same error:
Error in query: SELECT * FROM APP_DELEGATION WHERE PRO_UID='55715942357ee29b8ad42a1031567995' AND TAS_UID='49792480457ee2a0c0a4c97044786568' AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '2016-10-27 12:25:09'

I corrected the task and process ID and the task duration is set to 1 day but still no success. Kindly suggest what to do
By michaeltimoteo
#787194
Hi processmaker

Can you store the value of $aCase on a PM Variable like @@sql_result and see in the debug mode what happen to the @@sql_result?

Also kindly edit the query like
Code: Select all
$sql = "SELECT * FROM APP_DELEGATION WHERE PRO_UID='$processId' AND TAS_UID='$taskId' 
  AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '$currentDate' ";
$aCases = executeQuery($sql) or die("Error in query: $sql");
@@sql_result = $aCases;
to
Code: Select all
SELECT * FROM APP_DELEGATION WHERE PRO_UID='55715942357ee29b8ad42a1031567995' AND TAS_UID='49792480457ee2a0c0a4c97044786568' AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '2016-10-27 23:59:59'
User avatar
By amosbatto
#787213
Oops, I see that I forgot to call LoadCase() in my code, so you are going to get trigger errors. Try it this way:
Code: Select all
$processId = '616783822574cf2978e4021022999229'; //set to process where overdue tasks
$taskId    = '765123173574cf41b505353098774041'; //set to ID of task to check if it is overdue
$currentDate = date('Y-m-d H:i:s');
$sql = "SELECT * FROM APP_DELEGATION WHERE PRO_UID='$processId' AND TAS_UID='$taskId'
  AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '$currentDate' ";
$aCases = executeQuery($sql) or die("Error in query: $sql");

foreach ($aCases as $aCase) {
   $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
   $aUserInfo = userInfo($aCase['USR_UID']);
   $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
   
   $c = new Cases();
   $aCaseInfo = $c->LoadCase( $aCase['APP_UID'] );
   PMFSendMessage($aCase['APP_UID'], $from, $to, '', '',
      "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array());
}
Also remember to create your "overdue.html" template file.
By processmaker
#787218
amosbatto wrote:Oops, I see that I forgot to call LoadCase() in my code, so you are going to get trigger errors. Try it this way:
Code: Select all
$processId = '616783822574cf2978e4021022999229'; //set to process where overdue tasks
$taskId    = '765123173574cf41b505353098774041'; //set to ID of task to check if it is overdue
$currentDate = date('Y-m-d H:i:s');
$sql = "SELECT * FROM APP_DELEGATION WHERE PRO_UID='$processId' AND TAS_UID='$taskId'
  AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '$currentDate' ";
$aCases = executeQuery($sql) or die("Error in query: $sql");

foreach ($aCases as $aCase) {
   $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
   $aUserInfo = userInfo($aCase['USR_UID']);
   $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
   
   $c = new Cases();
   $aCaseInfo = $c->LoadCase( $aCase['APP_UID'] );
   PMFSendMessage($aCase['APP_UID'], $from, $to, '', '',
      "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array());
}
Also remember to create your "overdue.html" template file.
Thanks for replying but even with the change in trigger code I'm getting the following error:
Error in query: SELECT * FROM APP_DELEGATION WHERE PRO_UID='55715942357ee29b8ad42a1031567995' AND TAS_UID='49792480457ee2a0c0a4c97044786568' AND DEL_THREAD_STATUS='OPEN' AND DEL_TASK_DUE_DATE < '2016-10-28 09:26:34'

And i have already created an empty template of overdue.html
By fibo2358
#812659
Hello,

It seems that the trigger produces an error also when there are no cases matching the sql query ("0 row(s) returned")
I changed the code from:
Code: Select all
$aCases = executeQuery($sql) or die("Error in query: $sql"); 

foreach ($aCases as $aCase) {
   $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
   $aUserInfo = userInfo($aCase['USR_UID']);
   $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
   
   $c = new Cases();
   $aCaseInfo = $c->LoadCase( $aCase['APP_UID'] );
   PMFSendMessage($aCase['APP_UID'], $from, $to, '', '',
      "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array());
} 
To:
Code: Select all
if (is_array ($aCases) and count($aCases) > 0 ) {
   foreach ($aCases as $aCase) {
      $from = 'admin@example.com'; //make sure to set this to same email as configured in ADMIN > Email Servers
      $aUserInfo = userInfo($aCase['USR_UID']);
      $to = '"'.$aUserInfo['firstname'].' '.$aUserInfo['firstname'].'" <'.$aUserInfo['mail'].'>';
   
      $c = new Cases();
      $aCaseInfo = $c->LoadCase( $aCase['APP_UID'] );
      PMFSendMessage($aCase['APP_UID'], $from, $to, '', '',
         "Case ".$aCaseInfo['APP_TITLE']." is overdue", 'overdue.html', array());
   }
}
 
Now I do not see the "Error in query.." error.

Are you looking for a more intelligent approach to[…]

The 1Win Clone Script is a pre-built solution that[…]

Aviator Clone Script replicates the renowned Aviat[…]

From converting physical assets into digital asset[…]