Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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.
#814329
Hi,
I have a challenge and hope you are able to recommend a simple way to approach it. I already created one approval process. Sometimes, cases created from this process need modification. I'm thinking of creating a separate yet the same process to modify the cases, but I don't know how I can auto-populate the fields in the case created by the new process with the data from the complete case in the initial process. Also, I want to be able to save the modified case as a new case instead of overriding an existing case. I hope this makes sense, but if it doesn't, please let me know.

My other question is: Is it possible to send/receive a message between completely separate processes?

Any suggestion or example would be very much appreciated.

Thanks
#814333
Hi sokunthearithmakara,
You can achieve this using sub-processes, you can take a look at the following link: http://wiki.processmaker.com/3.2/Sub-Processes

For example, i did a simple process where i insert my name and my email, then i add a sub-process which is related to a second process where i retrieve the data from my initial process and i'm able to modify it. When running a case, two cases are created, and data from sub-process doesn't override data from my initial process. I attach some images describing the process.
Selection_011.png
Selection_011.png (31.09 KiB) Viewed 3707 times
This are the two process, process A is my initial process, and Process B is the process that retrieves data from Process A.
Selection_012.png
Selection_012.png (7.01 KiB) Viewed 3707 times
This is Process A, in my first task i have a dynaform where i fill data such as name and email.
Process 2 is a sub-process, which is linked to Process B, using this sub-process it's is possible to send information from process A to Process B.
Selection_014.png
Selection_014.png (9.42 KiB) Viewed 3707 times
After running a case, two cases are created, first we have process A, where data is filled for first time. The second case is of Process B which recovers data from process A and we modify it.
Selection_015.png
Selection_015.png (5.8 KiB) Viewed 3707 times
This is the form of Process A.
Selection_016.png
Selection_016.png (7.06 KiB) Viewed 3707 times
This is the form of process B

Hope you find this helpful, regards,
Carlos
#814342
Hi Carlos,

Thank you so much for your detailed response. I guess the only problem with this solution is that it creates two cases every time and the process will remain in progress unless users take actions in both processes. In my scenario, not all cases require modification. Users should be able to start a modification process only when necessary.

But this is a good start. I'll give this a try and let you know.

Thanks,
Thearith
#814357
Hi sokunthearithmakara,
the solution to do this is using asynchronous sub-processes, in the example I gave you before i was using a synchronous sub-process, synchronous sub-processes demand the execution of the sub-process in order to en the initial process. Using an asynchronous sub-process you can execute the initial task with no mandatory execution of the sub-process. I suggest you take a look to the documentation where you can find more detailed information: http://wiki.processmaker.com/3.2/Sub-Processes

Regards,
Carlos
#814370
Another solution is use a trigger to start a new case with the same data. For example, if the user marks a checkbox associated with a variable named "startNewCase", then you can do something like this:
Code: Select all
$startingTaskId = '1234567890abcdef1234567890abcdef'; //set to ID of starting task in process
$startingUserId = 'abcdef234567890abcdef1234567890'; //set to the ID of user to start new case

if (!empty(@=startNewCase) and @=startNewCase[0] == 1) {
   $oCase = new Cases();
   $aCaseInfo = $oCase->LoadCase(@@APPLICATION, @%INDEX);
   $aVars = $aCaseInfo['APP_DATA'];

   //remove system variables from the case variables:
   $aSysVars = array('USER_LOGGED', 'USR_USERNAME', 'APPLICATION', 'INDEX', 'PIN', 
      'PROCESS',  'TASK', 'SYS_LANG', 'SYS_SKIN', 'SYS_SYS', '__ERROR__');
   
   foreach ($aSysVars as $varKey => $varVal) {
      if (array_key_exists($varKey, $aVars)) {
         unset($aVars[$varKey]);
      }
   }
   $newCaseId = PMFNewCase(@@PROCESS, $startingUserId, $startingTaskId, $aVars);
   if ($newCaseId) {
      $aNewCaseInfo = $oCase->LoadCase($newCaseId, 1);
      $newCaseNo = $aNewCaseInfo['APP_NUMBER'];
      $g = new G();
      $g->SendMessageText("New case #".$newCaseNo." was created.", "INFO");
   }
} 
See:
http://wiki.processmaker.com/3.2/Proces ... Case.28.29
http://wiki.processmaker.com/3.0/Intern ... Case.28.29
http://wiki.processmaker.com/3.0/Intern ... Text.28.29

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