Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#815421
HI,
We have a workflow wherein I want to add a functionality of that if anyone in the workflow rejects the case it goes back to Task1 and get assigned to initiator where it can be modified by initiator and again the complete workflow follows. Not sure which function to use.

..Raman
#815426
Hi,
Have seen this before posting but here the action happens on submit/button and we have to use trigger rather than decision box. Also this action can be done at point in at 20 task workflow and on doing that it should go to task 1 again and restart.
#815453
Hi Amos,
Issue is not to find use to whom the task will be assigned (as its taken care of in code) but how to send the task back to Task1 using a Button. There is no logical gate in workflow which decides to sent it back to Task1 but an approver can reject it at any of the 20 tasks in workflow so want to use trigger along with Button.

Can we use PMFRedirectToStep() in trigger to move the case to Step1 of Task1 without breaking the system ?

..Raman
#815457
Tried using PMFRedirectToStep() but getting error The row '8874772455b61b8c51d1fd2053949088, 3' in table AppDelegation doesn't exist! in UI. I have used the below in trigger :
PMFRedirectToStep(@@APPLICATION, @%INDEX, 'DYNAFORM','4762728885b45dbba5d4037017076676');
Where the numeric thing is STEP_UID_OBJ.
#815471
Raman,
PMFRedirectToStep() is only used to redirect to a step in the current task. You will have to add exclusive gateways and a route back to the original task after every task. ProcessMaker only allows cases to be routed along paths in the process map.

Another option is to start a new case with PMFNewCaseImpersonate() in a trigger and pass all the variables from the current case to the new case. Then, cancel the current case.
Here would be the trigger code:
Code: Select all
$aSystemVars = array('SYS_SYS', 'SYS_LANG', 'SYS_SKIN', 'APPLICATION', 'INDEX', 'PROCESS', 'TASK', 
    'USER_LOGGED', 'USR_USERNAME', 'APP_NUMBER', 'PIN', '__ERROR__');
if (@@restartCase == 'yes') {
     //get user who started this case:
     $c = new Cases();
     $aCase = $c->LoadCase(@@APPLICATION);
     $firstUserId = $aCase['APP_INIT_USER'];
     
     //remove the system variables from the variables to pass to the new case:
     $aVars = $aCase['APP_DATA'];
     unset($aVars['restartCase']);
     foreach ($aCase['APP_DATA'] as $varName => $varValue) {
         if (in_array($varName, $aSystemVars)) {
            unset($aVars[$varName]);
         } 
     }
     //start a new case with the data and first user from the current case:
     if (PMFNewCaseImpersonate(@@PROCESS, $firstUserId, $aVars)) {
         //lookup the new case in the database:
         $sql = "SELECT MAX(APP_NUMBER) AS CASE_NUMBER FROM APPLICATION WHERE PRO_UID='".
             @@PROCESS."' AND APP_INIT_USER='$firstUserId'";
         $result = executeQuery($sql);
         if (empty($result)) {
              throw new Exception("Unable to find new case in APPLICATION table");
         }
              
         $newCaseNo = $result[1]['CASE_NUMBER'];
         $aUser = $userInfo($firstUserId);
         $fullName = $aUser['firstname'] .' '. $aUser['lastname'] .' ('. $aUser['username'] .')';

         //send email to the first user informing him/her that the case has been restarted 
         PMFSendMessage(@@APPLICATION, 'admin@example.com', $aUser['mail'], '', '', 
              'Case #'.@@APP_NUMBER.' restarted as case #'.$newCaseNo, 'restartedCase.hmtl');
     
         //cancel the current case:
         PMFCancelCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
         print "Current Case #".@@APP_NUMBER.
              " canceled and restarted as case #$newCaseNo assigned to $fullName.";
         die;
    } 
}
(This code might require some debug, since I'm writing it off the top of my head, but it gives you the basic idea.)
Set this trigger to fire before assignment in every task in the process.

Then, add a button with the ID "restartCaseButton" and a hidden field with the ID and variable "restartCase" to your Dynaforms.

Then, add this JavaScript to your Dynaforms:
Code: Select all
$("#restartCaseButton").find("button").click(function(){
  $("#restartCase").setValue("yes");
});
This is the basic idea of what this JavaScript is doing: https://wiki.processmaker.com/3.0/Submi ... ancel_Case

Finally, add an email template with the filename "restartedCase.html" that is used by PMFSendMessage().

In the rapidly evolving world of online sports be[…]

STEPN integrates social networking and games that […]

Cenforce 150 is a medication used to cope with a c[…]

What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]