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.
By maabik
#825649
Hi,
I have to implement the workflow in the attached file:
In “Task 1”, when the user sends a form to be validated, two tasks will be created in parallel: “Task 2” and “Task 3”.
In “Task 3”, when the validator validates the form, “Task 4” will be created.
However, if the validator rejects the form, that will be sent to “Task 1” and “Task 2” must be ended.
My question to you is how to end a task after a validation check?can we do it using a code? Is there any trigger (code) example?
Thank you for your help.
Kind Regards.
Attachments
Workflow sample.png
Workflow sample.png (16.35 KiB) Viewed 1253 times
By maabik
#826512
Hi,

First, i would thank you ror your feedbak.

Actually, your code makes an end to the parallel task as expected but i have an issue. i am executing two other triggers after routing wish both are executed twice (saving and sending mail twice). those two triggers are working fine if emove the trigger that ends the parallel task. my code is the following:
Code: Select all
//set to title of other parallel task:
	$otherParallelTask = 'Task1';
	$caseTile = @@caseTitle;
	$opTaskId = PMFGetTaskUID($otherParallelTask);
	
	if (empty($opTaskId)) {
		throw new Exception("Task '$otherParallelTask' not found!");
	}
	
	//look up other parallel task's delegation index in the database:
	$caseId = @@APPLICATION;
	$sql = "SELECT * FROM APP_CACHE_VIEW WHERE APP_UID='$caseId' AND 
		TAS_UID='$opTaskId' AND DEL_THREAD_STATUS='OPEN' ORDER BY DEL_INDEX DESC";
	$aTasks = executeQuery($sql);
	
	//if another open parallel task is found, then route it on:
	if (!empty($aTasks)) {
		$g = new G();
        $g->sessionVarSave();
		@@ret = PMFDerivateCase($caseId, $aTasks[1]['DEL_INDEX'], false, $aTasks[1]['USR_UID']);
        $g->sessionVarRestore();
       
	}
can you please help me on this?
User avatar
By amosbatto
#826537
What version of ProcessMaker are you using? There is a bug is some versions of PM that prevents more than one trigger from executing during routing. Try combining your triggers into one trigger. For example, if you have 2 triggers after routing, then put the code from the two triggers into one trigger.
By maabik
#826548
Hi,

I am using the cloud verion of PM"3.3.0 - Enterprise Edition".
Even i combined all triggers in one, the execution is done twice (i got the results doubled).
I tried to use the function "PMFDeleteCase()" to delete the desired case but i does not work since its returned value is 0.

any suggestions please?
User avatar
By amosbatto
#826549
PMFDeleteCase() only works when deleting a case which is still in the first task of its process. If in a later task, you need to use PMFCancelCase().

This line of code:
@@ret = PMFDerivateCase($caseId, $aTasks[1]['DEL_INDEX'], false, $aTasks[1]['USR_UID']);

sets the third parameter to false, so it routes on the other parallel task without executing any of its triggers in routing.

It is impossible for me to tell you why your triggers are executing twice without seeing your process. Post the .pmx file for your process and tell me exactly which triggers are executing twice and in which task.
Multiple Uploader in Grids

Are you trying to show all the uploaded files in[…]

Thanks!

HOW TO INCLUDE THE GULLIVER PHP

Hi. The gulliver script needs to be executed insi[…]

VS CODE AND GITLAB

Hi. I suggest you to use GitHub. I consider Git[…]