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

Moderator: amosbatto

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 medoman
#788044
Hello my friends
i need to fire an automatic Email to someone who in not included in the process (supervisor) if the task duration ends... i don't know how to do that ... can you help me please?
By zainab
#788075
Please refer to the below link, to design the trigger for sending an email notification when the task duration ends.

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

To send an email to the supervisor, you need to run the following query to get the of the supervisor of the department:
Code: Select all
$query="select USR_EMAIL from USERS where USR_UID = (select DEP_MANAGER from DEPARTMENT where DEP_UID = (select DEP_UID from USERS where USR_UID = '".$user."'))";
$result=executeQuery($query);
if(is_array($result) and count($result)>0)
{
$sup = $result[1]['USR_EMAIL'];

}
$result contains the email of the supervisor of a particular employee you want to send an email to.

Then use PMFSendMessage(@@APPLICATION, $emailFrom, $sup, ' ', ' ', 'Overdue case ' . $aCase['APP_TITLE'],
'overdueCase.html', $aData);

I hope it helps.
Last edited by zainab on Wed Dec 28, 2016 11:21 pm, edited 1 time in total.
#813033
Hello Everyone,

I´m a newbie in PM, and currently trying to develop this process:
via web entry an employee1 provided with a url can start a case trough a Dynaform.
for the next task i´m using a script wich holds information from the mentioned Dynaform filled by employee1, such as expiration date, and email of the employee2 who has to answer a question in the Dynaform.
The Dyaform in question is sent to the employee2 via actionsbyemail.
the next task is to evaluate the response of employee 2 that response comes to the PM inbox, but before getting that response i want to add a task that sends an email to the employee2 if he hasn´t replied in the aforementioned Dynaform. (send an email after a task duration ends. but that duration or due date is set in the dynaform).

i have successfully run the case without the validation of the duedate.
in order to evaluate the due date i have created a trigger to update the DEL_TASK_DUE_DATE, which is functional.

Can anyone Help me to Achieve this?

Any help would be appreciated, Thanks to this awesome forum in advance.

Attached is my process.

Regards

Ironbot.
Attachments
#813037
Ironbot, You will need to create a separate process that periodically executes a trigger like this:
SendEmailIfTaskNotCompleted.png
SendEmailIfTaskNotCompleted.png (15.99 KiB) Viewed 2046 times
1. Set the intermediate timer event to periodically execute every 20 minutes.
2. 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.
3. Then, create the following trigger in the process:
Code: Select all
//find the task ID by running a case in the other process and look at the TASK system variable:
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXX';
//set to the same email address used in Admin > Settings > Email Servers:
$emailFrom = '[email protected]';

$g = new G();
$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");
}

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']);

   @@mailSent = PMFSendMessage(@@APPLICATION, $emailFrom, $aUser['mail'], '', '', 
       'Overdue case ' . $aCase['APP_TITLE'], 'overdueCase.html', $aData);
       
    print "\nSending email to {$aUser['mail']} for case {$aCase['APP_TITLE']}\n";
}
Set the value of the $taskId in the code and set this trigger to be executed by the script task.

4. Then start a case in this process and route it to the script task so it will run forever.

5. Then manually execute the timereventcron.php file on your ProcessMaker server to check that this script is functioning correctly. You will have to execute it at least two times after you have an overdue case in the other process to see it work. The first time it runs, it will set the time when it will execute, so the second time it will execute.

6. Once you have verified that it works correctly without errors, then configure your ProcessMaker server to periodically execute the timereventcron.php file. See: http://wiki.processmaker.com/3.2/Execut ... nux.2FUNIX
#821878
Wise Amos,

I was away for a while but, in my return I tested your solution wich let me tell you works great.

I had a problem sending copies of the email to people outside PM, but i managed to send the variables from the master process to a report table to query them adding some code to the trigger you provided me.

I am greatful and hope to contribute as my understanding grows.

I do have a question, how to use variables from another process in the template of the reminder?, the master process variables are on a PM report table, but I dont know how to access them to show in the template, the variables i´m talking about are: a custom duedate (@@fechavencimiento in the master process) wich fires the loop, the name of the receiver of the copy of the reminder email.

though I call the 1st process "master" I clearify that the 2nd process is not a subprocess (that would have made my work easier :( i didnt use the sub process because i dont want to generate a case each time the reminder loop fires.)

If you could give me some advice on how to achieve this I´ll be even more in debt with this awesome forum.

Cheers,

Ironbot
#821881
Ironbot wrote: Fri Nov 30, 2018 11:52 am I do have a question, how to use variables from another process in the template of the reminder?, the master process variables are on a PM report table, but I dont know how to access them to show in the template, the variables i´m talking about are: a custom duedate (@@fechavencimiento in the master process) wich fires the loop, the name of the receiver of the copy of the reminder email.

though I call the 1st process "master" I clearify that the 2nd process is not a subprocess (that would have made my work easier :( i didnt use the sub process because i dont want to generate a case each time the reminder loop fires.)

If you could give me some advice on how to achieve this I´ll be even more in debt with this awesome forum.
You need to some way to identify the case in the "master" process, so you can look it up in the report table. You can use a variable n the case which has a unique value or the case number or the case ID.

Let's assume that the user enters the case number from the other case in a field associated with the otherCaseNo variable. Then, you can use this trigger code to look it up in the Report Table:
Code: Select all
if (!empty(@@otherCaseNo)) {
     $otherCase = (int) @@otherCaseNo; //convert from string to integer
     $sql = "SELECT * FROM PMT_MY_REPORT WHERE APP_NUMBER=$otherCase";
     $result = executeQuery($sql);
     if (empty($result)) {
         throw new Exception("Unable to find Case #$otherCase in table PMT_MY_REPORT.");
     }
     
     $aData = array(
          'field1' => $result[1]['FIELD1'],
          'field2' => $result[1]['FIELD2'],
          //add all the other variables here
     );
     //send variables from other case to be inserted in email template:
     @@mailSent = PMFSendMessage(@@APPLICATION, $emailFrom, $aUser['mail'], '', '', 
       'Overdue case ' . $aCase['APP_TITLE'], 'overdueCase.html', $aData);
}
populate grids with trigger

Is your question how to populate a grid with a dat[…]

You can try using this: $mssqlId = '123456789abcd[…]

Changing the login page

In your pmos.conf, try changing from: Redirec[…]

I've created two endpoints for dealing with docume[…]