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 sonylam
#787575
Dear any Master,

i has a case was paralled to 3 person, if one person was reject the case , i want the case was delete ( another 2 person will not show the case and end the case),

i search the example:
http://wiki.processmaker.com/index.php/Trigger_Examples

Routing (Derivating) all Parallel Tasks in a Case
Code: Select all
//if set, then a decision was submitted by the manager
if (isset(@@ManagerDecision)) {
    $caseId= @@APPLICATION;
    $userLogged = @@USER_LOGGED;
    $index = @%INDEX;
    //Select all the other parallel tasks for the current case that are still open
    $query = "SELECT DEL_INDEX, U.USR_USERNAME FROM APP_DELEGATION AD, USERS U ".
       "WHERE AD.APP_UID = '$case_id' AND AD.DEL_THREAD_STATUS='OPEN' AND " .
       "AD.USR_UID = U.USR_UID AND AD.DEL_INDEX <> $index";
    $threads = executeQuery($query);
    if (is_array($threads) and count($threads) > 0) {   
       foreach ($threads as $thread) {
          //Login as the assigned users and route on their tasks 
          $sql = "SELECT USR_PASSWORD FROM USERS WHERE USR_USERNAME = '{$thread['USR_USERNAME']}'";   
          $task_user = executeQuery($sql,'rbac');                   
          if (is_array($task_user) && count($task_user) > 0) {
              $pass = 'md5:' . $task_user[1]['USR_PASSWORD'];
              WSLogin($thread['USR_USERNAME'], $pass);
              WSDerivateCase($case_id, $thread['DEL_INDEX']);
          }
       }   
    }
}
i dont understand the "if (isset(@@ManagerDecision))" ,
the @@ManagerDecision means what? means a managerdescision=??
in my case , personx_approve=0 , personx_reject=1(selection box) , the i change @@ManagerDecision = personx_reject=1

that`s example will pass the case for another 2 person , if i want to del the case , how to change the code or has another best idea ?

Please help me !!

Sony Lam
By michaeltimoteo
#787579
Hi,

Isset command in PHP check if that variable has a value.
So in the code @@Manager_decision have a value assigned in it, it will proceed to the code below and assigned the user logged and etc and perform the sql query.

In your case you should probably use
Code: Select all
if(isset(@@personx_reject){
if(@@personx_regect ==1)
{
//code here
}
})
in my opinion, use cancel case. Deleting case in Pm is trickier
Last edited by michaeltimoteo on Sun Nov 27, 2016 11:27 pm, edited 1 time in total.
User avatar
By amosbatto
#787584
You don't know if the variable has been set, so you first have to check whether the variable is set and if it is set, then you can check its value.
For example, if you have dropdowns named "person1_approve", "person2_approve" and "person3_approve" where a value of 1 means "approved" and a value of 0 means "rejected" , then your trigger code would be:
Code: Select all
if ( (isset(@%person1_approve) and @%person1_approve==0) or 
     (isset(@%person2_approve) and @%person2_approve==0) or
     (isset(@%person3_approve) and @%person3_approve==0) ) {
   @@return = PMFCancelCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
   G::header("Location: casesListExtJsRedirector");  //redirect back to Inbox
   die;  //die to prevent next step
}
By sonylam
#787609
Dear michaeltimoteo,

Thank you for yr explain.
Thank you very much.


Sony
By sonylam
#787610
Dear Amosbatto,

Thank you for your reply, i try to understand your code,

just learning programming, need to learning so much,

Thank you for your help so much.

Sony
By sonylam
#787628
Dear Amosbatto,

i try the code, it is very usefull,

when one person was rejected the case (for example this case no is 123),

Another person still has that case no 123 at the in box,

while another user click the case 123 , the case will be disappear,

i want to while another user click the case 123 at that inbox,

it will be display a alert box or some text message inform user that case was cancel,

i want to try to use the JavaScript to made the alert box or message,

i try to add the G.alert but no work,

after see more, JavaScript just can use on dynaform,
Code: Select all
if ( (isset(@%approve_Anthony) and @%approve_approve_Anthony==2) or
     (isset(@%approve_Frank) and @%approve_approve_Frank==2) or
     (isset(@%approve_Darwin) and @%approve_approve_Darwin==2) or
     (isset(@%approve_Wyamn) and @%approve_approve_Wyman==2) or
  	 (isset(@%approve_Frank) and @%approve_approve_Frank==2) or 
     (isset(@%approve_PFOL) and @%approve_PFOL==2) or 
     (isset(@%approve_QA) and @%approve_QA==2) or 
     (isset(@%approve_HFOL) and @%approve_HFOL==2)) {
   @@return = PMFCancelCase(@@APPLICATION, @%INDEX, @@USER_LOGGED);
   
   G.alert("Case was Cancel", "Case was Cancel");
   
      G::header("Location: casesListExtJsRedirector");  //redirect back to Inbox
   
   die;  //die to prevent next step
}
search the PM function, no one can suitable,

Can you give me some idea to make the pop up message?


Sony
User avatar
By amosbatto
#787650
In the trigger, you can either display a message with print "message"; or you can redirect back to the inbox with G::header(), but you can't do both.

The G.alert() function is JavaScript code, so it can't be used in a trigger, which uses PHP code.

You can add G.alert() to the submit event of your DynaForm:
Code: Select all
getField("submitButton").form.onsubmit = function() {
  if (getField("rejectField").value == 'yes') {
         G.alert("Cancelling Case", "Cancelling");
  } 
  return true; //return true to continue submit action
 }
Where "submitButton" is the name of your submit button and "rejectField" is the name of your dropdown to select whether to approve or reject.

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]