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.
#813287
Hi PM Gurus,

I'm trying to implement a sub-process on the newly created process . The idea is to create a quotation request when the [quotation needed] dropdown field from the master form (Process) is set to "Yes". The quotation request is already working as a separate process. Could you please assist me on how to implement this using triggers? I've read the KB article on sub-process but i'm not able to grasp the general idea on creating new case using sub-process.

What I want to achieve is to create a new case on VoyantQuotation sub-process and set the assignment rule of the new case to Self Service value based assignment.

Thanks, in advance
Attachments
Subprocess2.JPG
Subprocess2.JPG (40.13 KiB) Viewed 7861 times
Subprocess1.JPG
Subprocess1.JPG (45.07 KiB) Viewed 7861 times
#813303
1. Set the first task in your subprocess to Self Service Value Based Assignment and the variable to: @@usersList

2. Create a group named "Subprocess Users" and assign all the users to the group who you want to be assigned to the first task in your subprocess.

3. In your master process, add the following trigger:
Code: Select all
@=usersList = array();
  
//set to the name of the group whose members will be assigned to the first task in subprocess
$groupName = 'Subprocess Users'; 
$sql = "SELECT GU.USR_UID FROM CONTENT C, GROUP_USER GU 
  WHERE C.CON_CATEGORY='GRP_TITLE' AND C.CON_VALUE='$groupName' AND C.CON_ID=GU.GRP_UID";
$aUsers = executeQuery($sql);

foreach($aUsers as $aUser) {
   @=usersList[] = $aUser['USR_UID'];
}
Set this trigger to execute before assignment in the task before the subprocess.

4. Then in the properties of the subprocess in the master process, pass the @@usersList to the subprocess.
subprocessProperties.png
subprocessProperties.png (26.39 KiB) Viewed 7853 times
Note: If you want to automate this in a trigger, then you can first create a case in the master process with PMFNewCase() and then use PMFDerivateCase() to route that case to the subprocess.

Here are two processes to test it:
(13.96 KiB) Downloaded 333 times
This worked without any problem in PM 3.2.1, but when I imported these processes into PM 2.8.0, I found that Home > Unassigned cannot load the list of unassigned cases. I suspect that the problem is that the code in PM 2.8.0 is not compatible with PHP 5.6.20 and/or MySQL 5.5.47 which I have installed on my server. If you are using PM 2.5.2, you will probably need to use PHP 5.3 and MySQL 5.1 in order to get Self Service Value Based Assignment to work. If you have recent versions of PHP and MySQL, you will probably need to upgrade to a recent version of PM in order to get it to work.
#813438
Hi amosbatto,

Thank you for the reply and solutions.

I've tried the first solution you've suggested but the cases are not displayed on the UNASSIGNED folder. :(
I also tried automating this in a trigger at some point it works but all of a sudden it does not create a new case anymore. I even tried to hardcode all the values of the parameters and only calling the PMFNewcase but its return value is 0.

Below is the screenshot of the trigger content.
Attachments
Voyant2.JPG
Voyant2.JPG (58.62 KiB) Viewed 7836 times
Voyant1.JPG
Voyant1.JPG (57.46 KiB) Viewed 7836 times
#813454
Did the sample processes I gave you work on your installation of PM? If not, then the problem is your installation and you should post your versions of ProcessMaker, MySQL, Apache, PHP and the operating system.

If the sample processes worked, then you should export your processes and post the .pm files if you want help debugging the problem.
#813513
Hi amosbatto,

Thank you for reading my reply.

As requested, I've attached the .pm file on this message. I'm having issue with PMFNewCase that all of a sudden it does not create new case anymore.
I would like to make this working as using subprocess in 2.5.2 cannot load the list of unassigned cases (self service value based assignement) as what I've tried as a first solution but it doesn't work because we are using recent version of our PHP and MySQL.

Thanks, in advance.

Alfred
Attachments
(256.57 KiB) Downloaded 305 times
#813537
Hi Amosbatto,

Apologies that I did not provide the details. Anyhow, i'm trying to debug the trigger name (CreateVoyantQuotation). As the subprocess self-service value based-assignement does not display the cases on the UNASSIGNED folder, I would to automate the creation of new case on triggers as what you have suggested before.

Below are the information of our PM.
OS: WINNT
PM : 2.5.2
DB Server: MySQL 5.6.16
Web Server: Apache 2.4.7 (Win32) Open SSL /1.0 1h
PHP 5.5.9
Attachments
PMFNewCase.png
PMFNewCase.png (72.65 KiB) Viewed 7803 times
#813605
I don't know if this is causing the problem, but I see a couple problems with your trigger:
1. The parameter in PMFNewCase() should be the ID of the user assigned to the current task in the case, not the user's email address.
2. The index of the new case will always be 1 in the new case when calling PMFDerivateCase().
3. There is no reason to change the status of the case if you are going to immediately route it so delete that part.
4. PMFSendMessage() is missing the $bcc parameter, so you should be getting an error when you try to call the function. (check the __ERROR__ variable in the PM debugger). Also, PM has trouble sending email messages from other cases, because the $_SESSION variables have the wrong case number, delegation index and user logged, so it is better to send the email from the current case. Create your NextNotify.html template in the current process.

Try this code:
Code: Select all
$caseId = @@APPLICATION;
$query = "SELECT USR_UID FROM APP_DELEGATION WHERE APP_UID='$caseId' AND
    DEL_INDEX=(SELECT MAX(AD.DEL_INDEX) FROM APP_DELEGATION AD WHERE AD.APP_UID='$caseId')";
  
$result = executeQuery($query);
$aUser = userInfo($result[1]['USR_UID']);  
$to = $aUser['mail'];
//$submitter = @@VoyantRequesterId;
//  $assignedTo = 'alfred.sanosa@appliedmedical.com';

$taskId = '8553771975a8bf5ae9ad555037351717'; //set to starting task's unique ID
$processId = '8445434575a8bf5ae975ff7091090106'; //set to the process' unique ID

//set variables from the current case to send to the new case:
$aData = array('voyantRequesterName'=> @@VoyantRequesterName,
    'voyantCustName'=> @@CustomerName,'voyantCustNum'=> @@CustomerNumber);

$newCaseId = PMFNewCase($processId, $result[1]['USR_UID'], $taskId, $aData);
if (empty($newCaseId)) {
   throw new Exception("Unable to create new case with '$processId', '{$result[1]['USR_UID']}', '$taskId'.");
}
//delegation index should be 1 in the new case:
PMFDerivateCase($newCaseId, 1, false, $result[1]['USR_UID']); 

//make sure that the email you have in Admin > Email Servers is pm-alert@appliedmedical.com
PMFSendMessage(@@APPLICATION, 'pm-alert@appliedmedical.com', $to,'', '', 
    'Voyant Quotation Request for Approval', 'NextNotify.html');
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

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