Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By vsoqui
#18732
Hi there, I'm having a problem with my escalation process, first I'll explain whata needs to be done, then how am I doing it.
* How should it work:
After a user of the group "Initiators" approves a request each subsequesnt step of the path should wait 40 hours to see if the step has approved the request, if the 40 hours are done, the request (task or case as you wish to call it) should be reassigned to the user of the next level (a mail of notification needs to be sent) and wait another 40 hours. If those 40 are done, we reassign to the next level, and so on. At any point we are going to get to the initial user (it doesn't matter, it should be that way, basically it's a round robin kind of functionality). Each primary group will consist of 1 and ONLY 1 user, each escalation group can have 1 user assigned or none. So if my first primary group is IT_Tech, my escalation groups are IT_Tech_1, IT_Tech_2, etc... I know at this point if my primary group has a user assigned.

* What do I have:
I didn't knew if assign to the step the 40 hours of life time or the fact that I need it to be running indefinitely, I gave it a 365 days of life (on the properties of the step, on Timming Control)(Note: the Allow User Defined Timer Control checkbox is unchecked, if I check it the capture fields dissappear). Then I created an Intermediate Timer Event, I put it as a Single Task, Starts in IT_Tech Approval (My step name), Estimated Task Duration 365 Days, Execution time 0.001 days after interval starts, and to execute the following trigger:
Code: Select all
function getUserFromGroup($groupName) {
  $sql = "SELECT 
    GU.USR_UID, 
    CONCAT(U.USR_FIRSTNAME, ' ', U.USR_LASTNAME) AS DisplayName, 
    U.USR_Email
  FROM 
    `GROUP_USER` GU 
      INNER JOIN 
        `CONTENT` C 
      ON 
        GU.GRP_UID = C.CON_ID 
      INNER JOIN 
        `USERS` U 
      ON 
        GU.USR_UID = U.USR_UID 
  WHERE 
    UCASE(C.Con_Value) = UCASE('".$groupName."')";

  return executeQuery($sql);
}

function isValidUser($userData) {
    return (is_array($userData)) && (count($userData) > 0);
}

$currentGroup = @@Current_Group;
$escalationLevel = @@Escalation_Level;
$resultEsc = "";

  if($escalationLevel == '') {
    $escalationLevel = '_1';
    $resultEsc = getUserFromGroup($currentGroup.$escalationLevel);
  }

  if($escalationLevel == '_1' && !isValidUser($resultEsc)) {
    $escalationLevel = '_2';
    $resultEsc = getUserFromGroup($currentGroup.$escalationLevel);
  }

  if($escalationLevel == '_2' && !isValidUser($resultEsc)) {
    $escalationLevel = '';
    $resultEsc = getUserFromGroup($currentGroup.$escalationLevel);
  }

@@Next_User_ID    = $resultEsc[1]['USR_UID'];
@@Next_User_Name  = $resultEsc[1]['DisplayName'];
@@Next_User_Email = $resultEsc[1]['USR_Email'];

@@Escalation_Level = $escalationLevel;

$caseID = @@APPLICATION;

$result = executeQuery("SELECT count(APP_DOC_UID) as fileQty FROM APP_DOCUMENT WHERE APP_UID='$caseID'");
$fileQty = $result[1]['fileQty'];

$result = executeQuery("SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseID'");
$docID = $result[$fileQty]['APP_DOC_UID']; 

$fileName = $docID."_1.html";
$contents = file_get_contents("/opt/processmaker/shared/sites/workflow/files/".$caseID."/outdocs/".$fileName);

$userEmail   = @@Next_User_Email;
$caseNumber  = @@_Case_ID;

PMFSendMessage(@@APPLICATION, "Workflow Message", $userEmail, "xxxx@yyy.com", "", "Automatic Escalation  - Case #".$caseNumber." - New entries found", "OutputDoc.html", array('Contents'=>$contents)); // I've always sent a copy of the email to me.

$resultApp = executeQuery("SELECT USR_UID, DEL_INDEX FROM APP_DELEGATION WHERE APP_UID = '$caseID' ORDER BY DEL_INDEX DESC");
$currentUserID = $resultApp[1]['USR_UID'];
$currentIndex = $resultApp[1]['DEL_INDEX'];
$newUserID = @@Next_User_ID;

$objCase = new Cases();
$objCase->reassignCase($caseID, $currentIndex, $currentUserID, $newUserID);
So I create a new task, fill out the Initiator data, the flow goes to the IT_Tech Step, I wait arround 10-20 minutes and I get the message that the next user has the task, and the task or case disappears from my inbox and it appears on his/her inbox. The problem is that the Event is not run anymore... what's the problem here?

Please help me out guys..

Thanks in advance... :D
User avatar
By amosbatto
#18792
Do you see any error messages when you manually execute cron.php? Are there any errors in the cron.php log file? I would change the time from ".0001" to "0" and try it again. I don't think that ProcessMaker calculates time that small. Also, have you tried executing a trigger with very simple code at zero time after the task starts? Something like: @@x = 1;

Then open the case in ProcessMaker with the debugger running and see if the variable was set.
By georgew
#18850
I run into the same problem when using the reassignCase() function with getting the pending events to be created. I've placed the trigger into a task directly to use the debugger and see if there are any errors when opening the task, but there are no errors. The case is reassigned to the next user and that's all. Even setting up auto notifications on the tasks will not send out any emails, so I am thinking the reassignCase() function is not doing all the steps that would normally happen when moving to a new task.
User avatar
By amosbatto
#18856
You are right. reassignCase() isn't like a normal assignment and triggers associated with assignment don't fire and notifications aren't sent out. You will need to manually send out the emails with PMFSendMessage(). I will add a note to the documentation about this.
By vsoqui
#19196
amosbatto wrote:You are right. reassignCase() isn't like a normal assignment and triggers associated with assignment don't fire and notifications aren't sent out. You will need to manually send out the emails with PMFSendMessage(). I will add a note to the documentation about this.
Well finally I fixed my escalation issue with a custom PHP that runs after cron.php,
I extract all of the app_uids from my process, with status TO_DO and some other filters and joins,
I reset the last executed time of the event, update the index and mark the event as open and that took care of problems.

It would be nice that PM could take care of cases like this, where the Events could be executed more than once, maybe define the time of executions or a date of stopping or qty of days or maybe another condition (value from a variable or something like that.. )

Well, thanks a lot for the replies.. now. how do I close a topic? or they just stayed open?

Thanks.. :)
User avatar
By amosbatto
#19217
vsoqui wrote:It would be nice that PM could take care of cases like this, where the Events could be executed more than once, maybe define the time of executions or a date of stopping or qty of days or maybe another condition (value from a variable or something like that.. )

If you have a suggestion for how to improve ProcessMaker, file a bug report at http://bugs.processmaker.com and select "Yes" for the "New Feature Request" box at the bottom. The developers generally don't read this forum, so they don't notice people's comments.
vsoqui wrote:Well, thanks a lot for the replies.. now. how do I close a topic? or they just stayed open?
We leave all threads open (except for announcments), in case other people happen on a topic months later and want to leave a message.
By processmaker
#787278
[quote="vsoqui"][/quote]

Hello, can you please guide me through the whole escalation process because it seems you were facing the same problems as me and have already solved them. I want the same scenario on my process of sending an email after 40 hrs of being assigned the task. I'd be grateful.
By processmaker
#787279
Hello, can you please guide me through the whole escalation process because it seems you were facing the same problems as me and have already solved them. I want the same scenario on my process of sending an email after 40 hrs of being assigned the task. I'd be grateful.[/quote]

Being the best in the started business is the obje[…]

Winzo is a popular and unique game on the mobile p[…]

Cannot create process using templets

Real details. The problem was solved by effect!

However, it is essential to use it responsibly and[…]