Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

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.
#824906
Hi,
There were some strange issues happening with duplicate cases created (PMFCreateNewCase()) by a trigger fired on "before routing" and I'm assuming this could be due to the use of Edge (or other) browser different from Firefox! Do you have any tip?
Now, I need to pause (i wanted to cancel or delete if possible?) these cases and the system is poping up the error message: "The case has not stopped due to its trigger".
What it's happening here?
Thank you very much.
#824909
Thanks Amos.
See the code below:
Code: Select all
//TRIGGER
$taskId    = '1986389165ba25200c004b7024400992';  //set to starting task's unique ID
$processId = PMFGetProcessUidByName("განყოფილების მომსახურება");  //set to the process' unique ID
//$processId = PMFGetProcessUidByName("Service at Division");  //set to the process' unique ID
$userLogged = @@USER_LOGGED;
//Only the rows not marked as Refused will generate services. They were removed before
for ($j = 1; $j <= count(@=gridDivision); $j++) {
	$aData = array(     
		'OrderID'    				=> @%OrderID,
		'OrderNumber'    			=> @@OrderNumber,
		'OrderCustomerNumber' 		=> @@OrderCustomerNumber,
		'ContractID'    			=> @%ContractID,
		'ContractNumber'    		=> @@ContractNumber,
		'ContractCustomerNumber'   	=> @@ContractCustomerNumber,
		'ContractDate'			   	=> @@ContractDate,
		'TypeOfService'    			=> @=gridDivision[$j]['TypeOfService'],
		'TypeOfServiceName'    		=> @=gridDivision[$j]['TypeOfServiceName'],
		'MiName'    				=> @=gridDivision[$j]['Title'],
		'MiServiceLocal'    		=> @=gridDivision[$j]['ServiceLocal'],
		'MiSerialNumber'    		=> @=gridDivision[$j]['SerialNumber'],
		'Division'    				=> @=gridDivision[$j]['DivisionID'],
		'ServicePlanNote' 			=> @=gridDivision[$j]['Note'],
		'DivisionName'				=> @@DivisionUser,
		'CustomerID'				=> @%CustomerID,
		'CustomerName'				=> @@CustomerName,
		'ContactName'				=> @@ContactName,
		'ContactMobile'				=> @@ContactMobile,
		'ContactEmail'				=> @@ContactEmail,
		'CustomerAddress'			=> @@InvoicingAddress
	);
	
	$newCaseId = PMFNewCase($processId, $userLogged, $taskId, $aData, "TO_DO");
	//This code it is needed to put the case in bold at Inbox
	$user_loged = @@USER_LOGGED;
	$user = @@USER_LOGGED;
	$userInfo = userInfo($user_loged);
	$query = "
		UPDATE `APP_CACHE_VIEW`
		 SET `USR_UID` = '".$user."', `DEL_INIT_DATE` = NULL, `APP_STATUS` = 'TO_DO',
			`PREVIOUS_USR_UID` = '".$user_loged."',
			`APP_DEL_PREVIOUS_USER` = '".$userInfo['lastname'].' '.$userInfo['firstname']."'
		WHERE `APP_UID` = '".$newCaseId."';
	";
	executeQuery($query);
	//}
}
#824938
Hi Amos,
Thanks again.
The next task is a "Value based assignment" and it is working fine for other users, but for this (it happen also with another) there are duplicated cases (it seems the trigger is executed more than once!). I suspected that it might be the Browser and I suggested to use Firefox (the one I use and never happen this in my tests) instead of Chrome. I also found out some issues with Edge (losing data on the swimlanes: disapearing tasks, assignment rules, flows).
For now, I just wanted to fix these Cases; removing them from inbox. Either by cancelling or pausing. The error appears when I tried to Pause. How can I do that?
Thanks.
#824950
You can manually create a record for the case in the APP_THREAD table, so that the case can be canceled or paused.

If you can't figure out what values to put in the APP_THREAD table, then I recommend that you simply delete the records for this case in the APP_DELEGATION, APP_CACHE_VIEW and APPLICATION tables to make the case disappear.
#825220
Thank you Amos.
This method is a work around, but the Cases continue to be duplicated after the aforementioned trigger!
- The trigger creates a new case with PMF_CreateNewCase();
- It is triggered on Before routing event of a Parallel task.
- Most of the duplicates are for the same user! Other users don't have duplicated cases on same task.
- It is created 1 case for each grid row. The grid is shown Ok to the user with no duplicated rows!

Do you know any possible cause?
I found out also that the Due-date is different for the duplicated cases - see picture attached.
Attachments
duplicates.png
duplicates.png (251.99 KiB) Viewed 1286 times
#825228
zeiscas wrote: Tue Jul 02, 2019 10:08 am This method is a work around, but the Cases continue to be duplicated after the aforementioned trigger!
- The trigger creates a new case with PMF_CreateNewCase();
- It is triggered on Before routing event of a Parallel task.
- Most of the duplicates are for the same user! Other users don't have duplicated cases on same task.
- It is created 1 case for each grid row. The grid is shown Ok to the user with no duplicated rows!

Do you know any possible cause?
This is bizarre. PMF_CreateNewCase() doesn't exist. Are you talking about PMFNewCase()? I recommend trying PMFNewCaseImpersonate() because it doesn't change the system variables.

There is a bug with triggers fired during routing in recent versions of PM. If you have multiple before routing triggers, then you need combine them into one trigger. What version of PM are you using?

Do you mind posting your trigger code?
#825255
executeQuery() has problems with ` (backticks) and ; (semicolons) in some circumstances. Also try resetting your system variables after calling PMFNewCase().

Try this:
Code: Select all
//TRIGGER
$taskId    = '1986389165ba25200c004b7024400992';  //set to starting task's unique ID
$processId = PMFGetProcessUidByName("განყოფილების მომსახურება");  //set to the process' unique ID
//$processId = PMFGetProcessUidByName("Service at Division");  //set to the process' unique ID
$userLogged = @@USER_LOGGED;
//Only the rows not marked as Refused will generate services. They were removed before
for ($j = 1; $j <= count(@=gridDivision); $j++) {
	$aData = array(     
		'OrderID'    				=> @%OrderID,
		'OrderNumber'    			=> @@OrderNumber,
		'OrderCustomerNumber' 		=> @@OrderCustomerNumber,
		'ContractID'    			=> @%ContractID,
		'ContractNumber'    		=> @@ContractNumber,
		'ContractCustomerNumber'   	=> @@ContractCustomerNumber,
		'ContractDate'			   	=> @@ContractDate,
		'TypeOfService'    			=> @=gridDivision[$j]['TypeOfService'],
		'TypeOfServiceName'    		=> @=gridDivision[$j]['TypeOfServiceName'],
		'MiName'    				=> @=gridDivision[$j]['Title'],
		'MiServiceLocal'    		=> @=gridDivision[$j]['ServiceLocal'],
		'MiSerialNumber'    		=> @=gridDivision[$j]['SerialNumber'],
		'Division'    				=> @=gridDivision[$j]['DivisionID'],
		'ServicePlanNote' 			=> @=gridDivision[$j]['Note'],
		'DivisionName'				=> @@DivisionUser,
		'CustomerID'				=> @%CustomerID,
		'CustomerName'				=> @@CustomerName,
		'ContactName'				=> @@ContactName,
		'ContactMobile'				=> @@ContactMobile,
		'ContactEmail'				=> @@ContactEmail,
		'CustomerAddress'			=> @@InvoicingAddress
	);
	
	$g = new G();
	$g->sessionVarSave();
	$newCaseId = PMFNewCase($processId, $userLogged, $taskId, $aData, "TO_DO");
	$g->sessionVarRestore();
	
	//This code it is needed to put the case in bold at Inbox
	$user_loged = @@USER_LOGGED;
	$user = @@USER_LOGGED;
	$userInfo = userInfo($user_loged);
	$query = "UPDATE APP_CACHE_VIEW
		SET USR_UID =  '$user', DEL_INIT_DATE = NULL, APP_STATUS = 'TO_DO',
		PREVIOUS_USR_UID = '$user_loged', 
		APP_DEL_PREVIOUS_USER = '{$userInfo['lastname']} {$userInfo['firstname']}'
		WHERE APP_UID = '$newCaseId'";
	executeQuery($query);
}
See: viewtopic.php?f=47&t=713218
#825371
Hi Amos,
I'm still trying to figure out what's going on. Client complaint about "duplicated cases" and I assumed it was due to this Trigger because it was the first ones we discovered. But I had changed the trigger position from "before assignment" to "before routing", and I guess, it worked out. But they were still complaining without identifying the Process/Task.
Then I found that it were appearing "ghost" cases when the process derivates to a sub-process. This "ghost" disapeared after the case returned to the main process. I applied that miraculous code on APP_DELEGATION. Insert trigger and this issue seems to be sorted out.
Now, I understood that they also have duplicated Case numbers!! (see picture). This one happen after first task and it is a simple Cycle derivation rule for 1 user (Director general). In all tasks I have groups of users assigned (most of them have only one user for now), but this task has only the user.
I'm using Processmaker 3.2.1 with multilanguage (English and Georgian).
Thanks for help.
Attachments
issue1.PNG
issue1.PNG (25.24 KiB) Viewed 1061 times
Amosbatto, PMUsers.com is down.

I get the same error message when trying to access[…]

Grid Attachment + Email Attachment

Hi, Please check this post: https://forum.process[…]

ID de Archivo en Grilla

Hi, You can use multipleFile in your grid, then se[…]

Problema Zona horaria

Hi, Change the timezone config in the "/opt/p[…]