Page 1 of 1

Cancel a case

Posted: Thu May 09, 2019 9:06 am
by HeshanKaru1994
Can you cancel a case on button click?

Re: Cancel a case

Posted: Thu May 09, 2019 12:19 pm
by rogerdeku
Hello HeshanKaru1994


Yes you can! cancel a case with a buttom click:

The cancel case action is based on the permission PM_CANCELCASE, which allows a user to cancel cases that have been assigned to them, and current user has Process Supervisor permissions.

Please keep in mind:

A case can't be canceled if more than one parallel thread is being executed (e.g. while using parallel gateways, parallel tasks and/or inclusive gateways).

Please read this guide to know more about it :wink:
https://wiki.processmaker.com/3.1/Cases#Cancel

Re: Cancel a case

Posted: Thu May 09, 2019 9:08 pm
by HeshanKaru1994
I was looking for a trigger to do that action. It is also good if that can close the open case also.

Re: Cancel a case

Posted: Thu May 09, 2019 9:33 pm
by amosbatto
If you are using PM 3.3.0 or later, you can cancel cases with parallel tasks.

If you want to do it in a trigger and redirect back to the Inbox, use this code:
Code: Select all
PMFCancelCase(@@APPLICATION);
header("Location: casesListExtJsRedirector");
die();
Your users need the PM_CANCELCASES permission in their roles to cancel cases. You can add a Cancel button to a Dynaform:
https://wiki.processmaker.com/3.2/Submi ... ancel_Case

Re: Cancel a case

Posted: Fri May 10, 2019 1:08 am
by HeshanKaru1994
So here you have to click cancel button and then submit the form. I want the implementation as once you click on the cancel button it routes to the end of the case.

Re: Cancel a case

Posted: Fri May 10, 2019 7:01 pm
by amosbatto
HeshanKaru1994 wrote: Fri May 10, 2019 1:08 am So here you have to click cancel button and then submit the form. I want the implementation as once you click on the cancel button it routes to the end of the case.
Canceling will stop the case at its current position in the process. Once you cancel the case, you can't route to the end of the case. If you want to route to the last task in the case, then you need to add a path to your process to skip to the last task in the process:
ProcessToSkipToEnd.png
ProcessToSkipToEnd.png (13.73 KiB) Viewed 1050 times
In the exclusive gateway, you can use the following routing rule:
routingRuleToSkipToEnd.png
routingRuleToSkipToEnd.png (28.03 KiB) Viewed 1050 times
Then, add the following controls to your Dynaform in "Task 1":
* A Submit button with the ID "cancelBtn"
* A Hidden field with the ID and variable "routeToLastTask"

Then, add the following JavaScript to your Dynaform:
Code: Select all
$("#cancelBtn").find("button").click( function() {
     $("#routeToLastTask").setValue("yes");
});
By the way, it is much easier to just go to Action > Cancel in the menu, if all you want to do is cancel the case.