Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By heemalkumar
#794519
Currently we have a process which is being sent to Officers for doing there Processing Work.
This works well where for a customer, there's just 1 processing to be done.

However, if a customer has 5 matters for processing, then we advise initiating officer to create 5 cases so each case can be assigned to different Officers for processing.

Request from business is, is there a way, if there is 5 matters matters for processing, can initiating officer create just 1 case, and then task is assigned 5 times to different processing officers?

Need some ideas please. Happy to answer questions if above post is not clear.
User avatar
By amosbatto
#794548
If you just want to do the same task a variable number of times, then you should see these solutions:
viewtopic.php?f=41&t=710262&p=789936#p789936
http://wiki.processmaker.com/3.0/Trigge ... r_of_Times

If you want separate cases, then I suggest that you create one process for the initiating officer and another process to handle each matter. Here is an example that might help you:
viewtopic.php?f=41&t=710164&p=793344&hi ... se#p793640
(See the example processes at the end of the thread.)

If you want to initiate new cases based upon the values entered in a grid, then the following trigger code will help you:
Code: Select all
$processId = '0123456789abcdef0123456789abcdef'; //set to the ID of the process to handle each matter
$firstTaskId =  '0123456789abcdef0123456789abcdef'; //set to the process's first task

//Randomly choose a user from the list of assigned users for the starting task:
if (isset(@=orderList) and is_array(@=orderList) > 0) {
   $d = new Derivation();
   $aUsers = $d->getAllUsersFromAnyTask($firstTaskId);
   shuffle($aUsers); //randomly shuffle the order of the users so same people aren't assigned every time:
   $msg = "Cases started: ";

   for ($i=1; $i <= count(@=orderList); $i++) {
       $userId = $aUsers[$i-1]; //subtract 1 because counting from 0, not 1

       //Create an associative array of case variables to pass to the new case from the grid:
       $aData = array(
           'itemName' => @=orderList[$i]['itemName'], 
           'quantity' => @=orderList[$i]['quantity'], 
           'orderDate' => @=orderList[$i]['orderDate'];
       );

       @@newCaseId = PMFNewCase($processId, $userId, $firstTaskId, $aData);
       if (empty($newCaseId)) {
          throw new Exception("Unable to create new case with process '$processId', task '$firstTaskId', user '$userId'.");
       }
   }
}
By heemalkumar
#794814
Thanks Amos.
Just a quick question, I can set a Parallel Gateway, where I can send a task to 5 different tasks.
However, there could be situations where Business would only want a matter to be sent to 1 instead of 5, how do I go about doing that?
User avatar
By amosbatto
#794819
heemalkumar wrote:Just a quick question, I can set a Parallel Gateway, where I can send a task to 5 different tasks.
However, there could be situations where Business would only want a matter to be sent to 1 instead of 5, how do I go about doing that?
You can use an inclusive gateway with conditions to determine how many of the parallel tasks will be executed. See this example:
http://wiki.processmaker.com/3.0/Trigge ... llel_Tasks

In the example, the number of parallel tasks to execute is determined by the number of users in a group, but you could have other criteria. For example, your trigger could be like this:
Code: Select all
function getUserId($username) {
   $u = new Users();
   if ($aUser = $u->loadByUsernameInArray($username)) {
       return $aUser['USR_UID'];
   } else {
       throw new Exception("User '$username' does not exist.");
   } 
}
if (@#orderAmount >= 500.0) {  
   @@userForTask1 =  getUserId("mary");
}
if (@#orderAmount >= 1000.0) {  
   @@userForTask2 =  getUserId("bob");
}
if (@#orderAmount >= 5000.0) {  
   @@userForTask3 =  getUserId("sarah");
}
if (@#orderAmount >= 20000.0) {  
   @@userForTask4 =  getUserId("harry");
}
Then, your conditions in the inclusive gateway could be:
Task1: isset(@@userForTask1) and !empty(@@userForTask1)
Task2: isset(@@userForTask2) and !empty(@@userForTask2)
Task3: isset(@@userForTask3) and !empty(@@userForTask3)
Task4: isset(@@userForTask4) and !empty(@@userForTask4)

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[…]