Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: amosbatto

#785448
Hi all,

I saw similar question here, but it wasn't explained clearly:

http://forum.processmaker.com/viewtopic ... 1&t=708808

Let's assume that I have process which consist of 2 tasks (Task_1 and Task_2).
I set Timing Control in Task_2 properties, so Task_2 should be completed in 2 days.
Now I would like processmaker to send mail notification to assigned users after 2 days passed and also same mail (or put additional mails to CC) of managers or other persons.

Can you please let me know how I can achieve it, since I couldn't find in documentation?

Thanks in advance.
#785455
Create a new process which has a single task and a DynaForm. Then create a email template file named "overdueCase.html" with the following content:
Code: Select all
Dear @#assignedUser,
The following case which is assigned to you is overdue:
Case No: @#caseNo
Case Title: @#caseTitle
Case Status: @#caseStatus
Current Task: @#taskName
When Assigned: @#taskAssigned
When Due: @#taskDue
Case Created By: @#caseCreatedBy
Case Start Date: @#caseStartDate
Case Last Updated: @#caseUpdatedDate
Link: @#caseLink
Please open the case and finish the task.
Then, create the following trigger and set it to fire before the DynaForm:
Code: Select all
//find the task ID by running a case in Task_2 and look at the TASK system variable:
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXX';
//set to the same email address used in Admin > Settings > Email Servers:
$emailFrom = '[email protected]'; 

$twoDaysAgo = date('Y-m-d H:i:s', strtotime('-2 days'));
$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
   DEL_TASK_DUE_DATE < '$twoDaysAgo' ";
$aCases = executeQuery($query);
if (!is_array($aCases)) {
   die("Error: Bad Query: $query\n");
}

foreach ($aCases as $aCase) {
   $c = new Cases();
   $aCaseInfo = $c->loadCase($aCase['APP_UID'], $aCase['DEL_INDEX']);
   $aData = array(
      'caseNo' => $aCase['APP_NUMBER'],
      'caseTitle' => $aCase['APP_TITLE'],
      'caseStatus' => '$aCase['APP_STATUS'],
      'taskName' => $aCase['APP_TASK_TITLE'],
      'taskAssignedDate' => $aCase['DEL_DELEGATE_DATE'],
      'taskDueDate' => $aCase['DEL_TASK_DUE_DATE'],
      'caseCreatedBy' => $aCaseInfo['CREATOR'],
      'caseStartDate' => $aCaseInfo['CREATE_DATE'],
      'caseUpdatedDate'=> $aCaseInfo['UPDATE_DATE'],
      'caseLink' => (G::is_https() ? "https://" : "http://") . $_SERVER['SERVER_NAME'] . 
          ':' . $_SERVER['SERVER_PORT'] . //comment out if no port number
          '/sys'[email protected]#SYS_SYS.'/'[email protected]#SYS_LANG.'/'[email protected]#SYS_SKIN.'/cases/open?APP_UID=' . 
          $aCase['APP_UID'] . '&DEL_INDEX=' . $aCase['DEL_INDEX'] . '&action=draft' 
   );
   $aUser = userInfo($aCase['USR_UID']);

   PMFSendMessage($emailFrom, $aUser['mail'], '', '', 'Overdue case ' . $aCase['APP_TITLE'], 
       'overdueCase.html', $aData);
}    
Run a case in this new process and verify that the trigger code works, but do not complete the case. Get the unique ID of the trigger and turn on the Debugger to get the case's ID found in the APPLICATION system variable. These IDs will be used used in the following script.

Then, go to the server running ProcessMaker and use a plain text editor to create a file named "checkOverdueCases.php" which is located in a place which isn't accessible to the internet. Add the following PHP code to the file:
Code: Select all
<?php
$serverAddress = "http://example.com"; //set to the server's address
$workspace = 'workflow'; //set to the workspace which is 'workflow' by default
$user = 'admin';  //set to user who is assigned to a case in the process to run trigger
$password = 'p4sSw0rD'; //set to password of the user
$caseId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to case's ID
$triggerId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to the trigger's ID

ini_set("soap.wsdl_cache_enabled", "0");
ini_set('error_reporting', E_ALL);
ini_set('display_errors', True);
      
$client = new SoapClient("$serverAddress/sys$workspace/en/neoclassic/services/wsdl2");
$md5Pass = 'md5:' . md5($password);
$params = array(array('userid'=>$user, 'password'=>$md5Pass));
$result = $client->__SoapCall('login', $params);
 
if ($result->status_code == 0)
   $sessionId = $result->message;
else
   print "Unable to connect to ProcessMaker.\nError Number: $result->status_code\n" .
         "Error Message: $result->message\n";
 
#look up the caseId and delIndex with the caseList() web service and the triggerIndex in MySQL
$params = array(array(
   'sessionId' => $sessionId, 
   'caseId' => $caseId,
   'triggerIndex' => $triggerId,
   'delIndex' => '1' //assuming first task in case
));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
else
   print_r($result);
?> 
This script uses the executeTrigger() web service to execute the same trigger code. (You can also use REST, but I recommend using web services because they are simpler and permit any registered user to login.)

After creating the "checkOverdueCases.php" file, then execute from the command line. In Linux/UNIX:
Code: Select all
php -f checkOverdueCases.php
In Windows, you will have to change to the directory where php.exe is located. For example:
Code: Select all
cd C:\Users\Bob\AppData\Roaming\ProcessMaker-3_0_1_7\php
php -f checkOverdueCases.php
After verifying that the script runs without any problems, then set the script to execute periodically as a Scheduled Task in Windows or a Cron job in Linux/UNIX. See: http://wiki.processmaker.com/3.0/Executing_cron.php

I haven't tested this code, so let me know if this example works, so I can add it to the wiki for others to use.
#786696
Dear All
I have tried the above solution, the only difference is that I need the trigger to send the message after 1 day. On review of the APP_CACHE_VIEW database I noticed some minor differences that I corrected.
Code: Select all
$taskId = '81312924357dfd963394c69047342114';

$emailFrom = '[email protected]';

$twoDaysAgo = date('Y-m-d H:i:s', strtotime('-1 days'));
$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
   DEL_TASK_DUE_DATE < '$twoDaysAgo' ";
$aCases = executeQuery($query);
if (!is_array($aCases)) {
   die("Error: Bad Query: $query\n");
}

foreach ($aCases as $aCase) {
   $c = new Cases();
   $aCaseInfo = $c->loadCase($aCase['APP_UID'], $aCase['DEL_INDEX']);
   $aData = array(
      'caseNo' => $aCase['APP_NUMBER'],
      'caseTitle' => $aCase['APP_TITLE'],
      'caseStatus' => $aCase['APP_STATUS'],
      'taskName' => $aCase['APP_TAS_TITLE'],
      'taskAssignedDate' => $aCase['DEL_DELEGATE_DATE'],
      'taskDueDate' => $aCase['DEL_TASK_DUE_DATE'],
      'caseCreatedBy' => $aCaseInfo['USR_UID'],
      'caseStartDate' => $aCaseInfo['APP_CREATE_DATE'],
      'caseUpdatedDate'=> $aCaseInfo['APP_UPDATE_DATE'],
      'caseLink' => (G::is_https() ? "https://" : "http://") . $_SERVER['SERVER_NAME'] . 
          ':' . $_SERVER['SERVER_PORT'] . //comment out if no port number
          '/sys'[email protected]#SYS_SYS.'/'[email protected]#SYS_LANG.'/'.@#SYS_SKIN.'/cases/open?APP_UID=' . 
          $aCase['APP_UID'] . '&DEL_INDEX=' . $aCase['DEL_INDEX'] . '&action=draft' 
   );	
		
   $aUser = userInfo($aCase['USR_UID']);

   PMFSendMessage($emailFrom, $aUser['mail'], '', '', 'Overdue case ' . $aCase['APP_TITLE'], 
       'overdueCase.html', $aData);
}
When I run checkOverdueCases.php command I receive the following response as attached.
(149.87 KiB) Downloaded 25 times
On running the cron.php script no emails are sent.
(69.52 KiB) Downloaded 25 times
The cron log on the server shows timereventcron as 'Failed'
(7.33 KiB) Downloaded 25 times
I am not sure if anyone else has tried this. If so can anyone help.

Thanks
Aza
#786702
It looks like you are using backticks ( ` ) instead of single quotation marks ( ' ) in your code. At least that is the way that DOS is showing them in your screenshot. That would cause problems in PHP.
#812695
amosbatto wrote:Create a new process which has a single task and a DynaForm. Then create a email template file named "overdueCase.html" with the following content:
Code: Select all
Dear @#assignedUser,
The following case which is assigned to you is overdue:
Case No: @#caseNo
Case Title: @#caseTitle
Case Status: @#caseStatus
Current Task: @#taskName
When Assigned: @#taskAssigned
When Due: @#taskDue
Case Created By: @#caseCreatedBy
Case Start Date: @#caseStartDate
Case Last Updated: @#caseUpdatedDate
Link: @#caseLink
Please open the case and finish the task.
Then, create the following trigger and set it to fire before the DynaForm:
Code: Select all
//find the task ID by running a case in Task_2 and look at the TASK system variable:
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXX';
//set to the same email address used in Admin > Settings > Email Servers:
$emailFrom = '[email protected]'; 

$twoDaysAgo = date('Y-m-d H:i:s', strtotime('-2 days'));
$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
   DEL_TASK_DUE_DATE < '$twoDaysAgo' ";
$aCases = executeQuery($query);
if (!is_array($aCases)) {
   die("Error: Bad Query: $query\n");
}

foreach ($aCases as $aCase) {
   $c = new Cases();
   $aCaseInfo = $c->loadCase($aCase['APP_UID'], $aCase['DEL_INDEX']);
   $aData = array(
      'caseNo' => $aCase['APP_NUMBER'],
      'caseTitle' => $aCase['APP_TITLE'],
      'caseStatus' => '$aCase['APP_STATUS'],
      'taskName' => $aCase['APP_TASK_TITLE'],
      'taskAssignedDate' => $aCase['DEL_DELEGATE_DATE'],
      'taskDueDate' => $aCase['DEL_TASK_DUE_DATE'],
      'caseCreatedBy' => $aCaseInfo['CREATOR'],
      'caseStartDate' => $aCaseInfo['CREATE_DATE'],
      'caseUpdatedDate'=> $aCaseInfo['UPDATE_DATE'],
      'caseLink' => (G::is_https() ? "https://" : "http://") . $_SERVER['SERVER_NAME'] . 
          ':' . $_SERVER['SERVER_PORT'] . //comment out if no port number
          '/sys'[email protected]#SYS_SYS.'/'[email protected]#SYS_LANG.'/'[email protected]#SYS_SKIN.'/cases/open?APP_UID=' . 
          $aCase['APP_UID'] . '&DEL_INDEX=' . $aCase['DEL_INDEX'] . '&action=draft' 
   );
   $aUser = userInfo($aCase['USR_UID']);

   PMFSendMessage($emailFrom, $aUser['mail'], '', '', 'Overdue case ' . $aCase['APP_TITLE'], 
       'overdueCase.html', $aData);
}    
Run a case in this new process and verify that the trigger code works, but do not complete the case. Get the unique ID of the trigger and turn on the Debugger to get the case's ID found in the APPLICATION system variable. These IDs will be used used in the following script.

Then, go to the server running ProcessMaker and use a plain text editor to create a file named "checkOverdueCases.php" which is located in a place which isn't accessible to the internet. Add the following PHP code to the file:
Code: Select all
<?php
$serverAddress = "http://example.com"; //set to the server's address
$workspace = 'workflow'; //set to the workspace which is 'workflow' by default
$user = 'admin';  //set to user who is assigned to a case in the process to run trigger
$password = 'p4sSw0rD'; //set to password of the user
$caseId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to case's ID
$triggerId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to the trigger's ID

ini_set("soap.wsdl_cache_enabled", "0");
ini_set('error_reporting', E_ALL);
ini_set('display_errors', True);
      
$client = new SoapClient("$serverAddress/sys$workspace/en/neoclassic/services/wsdl2");
$md5Pass = 'md5:' . md5($password);
$params = array(array('userid'=>$user, 'password'=>$md5Pass));
$result = $client->__SoapCall('login', $params);
 
if ($result->status_code == 0)
   $sessionId = $result->message;
else
   print "Unable to connect to ProcessMaker.\nError Number: $result->status_code\n" .
         "Error Message: $result->message\n";
 
#look up the caseId and delIndex with the caseList() web service and the triggerIndex in MySQL
$params = array(array(
   'sessionId' => $sessionId, 
   'caseId' => $caseId,
   'triggerIndex' => $triggerId,
   'delIndex' => '1' //assuming first task in case
));
$result = $client->__SoapCall('executeTrigger', $params);
if ($result->status_code != 0)
   print "Error: $result->message \n";
else
   print_r($result);
?> 
This script uses the executeTrigger() web service to execute the same trigger code. (You can also use REST, but I recommend using web services because they are simpler and permit any registered user to login.)

After creating the "checkOverdueCases.php" file, then execute from the command line. In Linux/UNIX:
Code: Select all
php -f checkOverdueCases.php
In Windows, you will have to change to the directory where php.exe is located. For example:
Code: Select all
cd C:\Users\Bob\AppData\Roaming\ProcessMaker-3_0_1_7\php
php -f checkOverdueCases.php
After verifying that the script runs without any problems, then set the script to execute periodically as a Scheduled Task in Windows or a Cron job in Linux/UNIX. See: http://wiki.processmaker.com/3.0/Executing_cron.php

I haven't tested this code, so let me know if this example works, so I can add it to the wiki for others to use.
hi amos,

i was using this method with bitnami installer. after that i installed manual installer PM 3.2.1. this script gave me an error about wrong paswoord. my password is same as old which is working with bitnami installer. i have also tried http://wiki.processmaker.com/3.0/Proces ... e_Database this one same error. i cant find any solution about it. can you help me ?
Attachments
Adsız.png
Adsız.png (114.17 KiB) Viewed 2112 times
#812701
azatrath,
I assume that you upgraded to a more recent version of MySQL that uses SHA256 in place of MD5 to store passwords.

In your code, change this line from:
Code: Select all
$md5Pass = 'md5:' . md5($password); 
To:
Code: Select all
$md5Pass = 'md5:'. hash('sha256',$password); 
#813171
Hello Amos,

I think that the possibility to send a reminder could be a standard functionality of ProcessMaker in the task definition, such as a time limit to claim a case:
(http://wiki.processmaker.com/3.1/Tasks# ... aim_a_case).
Is it possible to include such a functionality in a future version?
1. On the task level, the option to define a notification when the time is before to the task due-date.
2. On the task level, the option to define a notification when the time is after the task due-date.

Regards,
fibo2358
#813201
fibo2358 wrote:I think that the possibility to send a reminder could be a standard functionality of ProcessMaker in the task definition, such as a time limit to claim a case:
(http://wiki.processmaker.com/3.1/Tasks# ... aim_a_case).
Is it possible to include such a functionality in a future version?
1. On the task level, the option to define a notification when the time is before to the task due-date.
2. On the task level, the option to define a notification when the time is after the task due-date.
I agree, but I don't have any control over future development of PM.
If you want the PM developers to see this, please file a bug report about it at: http://bugs.processmaker.com

Hello everyone in previous versions of PM the ca[…]

Buen día, a todos Hace un par de día[…]

Perfecto amigo muchas gracias.

hello to all, please your help to resolve this dou[…]