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.
User avatar
By ethanthekiwi
#784770
My users don't often have the need to cancel cases, but one or two users do a high volume of cases and the need arises from time to time. Sometimes when I look, the Action menu shows that a case can be cancelled and it's quite simple for the user to do. Other times, no cancel option is available. Is there something that I can look at to fix that?

My other thought was that I could create a script to mark cases as cancelled in bulk. I've used the script to delete specific cases before (http://wiki.processmaker.com/index.php/ ... aker_Cases) but for auditing reasons, I would prefer to cancel cases. What would a script look like that would select multiple case numbers and change their status to cancelled?

ProcessMaker 2.8 on Debian
User avatar
By ethanpresberg
#784980
Are the cases that cannot be cancelled part of a parallel thread? If so, they would not be able to be cancelled until they all converge back onto a single thread.
User avatar
By ethanpresberg
#785012
Ethan,

Can you confirm one of these is true? If so, that would explain why you can't cancel it.

- The case is in TODO status. Cases in Draft status can't be canceled (cases in first task can't be canceled)
- Only users who have participated in the case are able to cancel it.
- The case can't be cancelled while it has more than one execution thread. (parallel tasks, result of parallel gateways and inclusive gateways can't be cancelled)

Note that the Cancelled status is a case status not a thread status, that's why we can't cancel threads individually.
By tamasig
#786484
Dear Ethan,

In your previous post, you write that
ethanpresberg wrote:the case can't be cancelled while it has more than one execution thread. (parallel tasks, result of parallel gateways and inclusive gateways can't be cancelled)
Still, is there a potential workaround the problem? I understand that it is the limitation of PMFCancelCase() that only the current task is cancelled (although I also did, for some reason, manage to cancel the parent task), but I can't seem to find a way to cancel any sister tasks as well as the parent task in a trigger that is supposed to fire when current sub-process task is cancelled. I tried the following code:
Code: Select all
$currentCaseId = @@APPLICATION;

$result = executeQuery("SELECT APP_PARENT FROM SUB_APPLICATION WHERE APP_UID='$currentCaseId'");

$parentCaseId = $result[1]['APP_PARENT'];

$cases = executeQuery("SELECT DISTINCT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='$parentCaseId' AND APP_UID<>'$currentCaseId'");

foreach ($cases as $case) 
{
      $caseId = $case['APP_UID'];   
      $index = $case['DEL_INDEX'];
      PMFCancelCase($caseId, $index, @@USER_LOGGED);
}

$result = executeQuery("SELECT DEL_INDEX FROM APP_DELEGATION AD WHERE  AD.APP_UID='$parentCaseId' ORDER BY DEL_INDEX DESC");

$index = $result[1]['DEL_INDEX'];

@@RETURN = PMFCancelCase($parentCaseId, $index, @@USER_LOGGED);
It does not, however, produce the desired effect. Any input would be highly appreciated.

Many thanks,
Gergely
User avatar
By amosbatto
#786492
ethanthekiwi wrote:My users don't often have the need to cancel cases, but one or two users do a high volume of cases and the need arises from time to time. Sometimes when I look, the Action menu shows that a case can be cancelled and it's quite simple for the user to do. Other times, no cancel option is available. Is there something that I can look at to fix that?
To answer ethanthekiwi's first question, you can cancel a case after it has gotten to the second or later task in the case. In the first task in the case, you can only delete it, meaning that the record for the case is removed from the APPLICATION table in the database. Normally a user can only cancel a case, if he/she is the assigned user to the current task in the case. However, users who have the PM_CANCELCASE permission in his/her role can cancel cases assigned to other users. You need to add that permission to your role in order to see the "Cancel" option in the "Action" menu if not assigned to the case.

@@Gergely, Does your logged in user have the PM_CANCELCASE permission in his/her role?
By tamasig
#786497
Dear Amos,

Many thanks for the fast reply.
Does your logged in user have the PM_CANCELCASE permission in his/her role?
Yes, they do.

Kind regards,
Gergely
User avatar
By amosbatto
#786513
Gergely,
Looking at your code, I think I see the problem. Try doing it this way:
Code: Select all
$currentCaseId = @@APPLICATION;

$result = executeQuery("SELECT APP_PARENT FROM SUB_APPLICATION WHERE APP_UID='$currentCaseId'");

$parentCaseId = $result[1]['APP_PARENT'];

$cases = executeQuery("SELECT DISTINCT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='$parentCaseId' AND APP_UID<>'$currentCaseId'");

//cancel sibling cases
foreach ($cases as $case) {
   $siblingId = $case['APP_UID'];
   //look up delegation index for the sibling case:
   $aSibling = executeQuery("SELECT DEL_INDEX FROM APP_DELEGATION WHERE APP_UID='$siblingId' ORDER BY DEL_INDEX DESC");	
   PMFCancelCase($siblingId, $aSibling[1]['DEL_INDEX'], @@USER_LOGGED);
}

//lookup index for parent case
$aParent = executeQuery("SELECT DEL_INDEX FROM APP_DELEGATION WHERE APP_UID='$parentCaseId' ORDER BY DEL_INDEX DESC");
//cancel parent case
@@RETURN = PMFCancelCase($parentCaseId, $aParent[1]['DEL_INDEX'], @@USER_LOGGED);
By the way, did you get your code from the wiki? (If so, it needs to be corrected.)
By tamasig
#786541
Dear Amos,

Many thanks for the fast reply and the correction supplied. I am afraid, however, that I am still running into problems. I have been testing the code, and under some circumstances (I am working on precisely delineating these) I receive a "Processing..." dialog which ultimately leads to the cancel task failing, but even in case the routine does manage to cancel the sibling cases the parent case does not get cancelled and is either stuck in to-do status (according to the Review menu item) or actually proceeds to run after the converging gateway.

In your last message, you were asking:
By the way, did you get your code from the wiki?
I tried to adapt some of the code snippets I found online, clearly messing it up, because there was no code addressing this exact issue posted in the wiki.

Kind regards,
Gergely
User avatar
By amosbatto
#786594
You might need to stop the subproceess case from continuing back to the parent case. At the end of your trigger code, try adding this:
Code: Select all
G::header("Location: casesListExtJsRedirector");
die;
This will redirect back to the Inbox. Does that solve the problem?
By tamasig
#786600
Dear Amos,
amosbatto wrote:Does that solve the problem?
I'm afraid it does not. As a matter of fact, in this scenario not even the case that I am actually cancelling gets cancelled.

Kind regards,
Gergely
User avatar
By amosbatto
#786610
OK, get rid of the redirector and die() statement. What is the value of @@RETURN? Is there an error message in @@__ERROR__ in the debugger ?
User avatar
By Ironbot
#814847
Hello, I´m not sure if this would help with what you´re trying to achieve(Im a noob)but I had a similar problem, my solution is not the best or the cleanest, but it gets the job done.
I assign the cases i want to cancel to a user who has no cases open, (this user is some sort of a dummy user we created for testing stuff) then i use a process to cancel the cases of that particular user.

here´s the post with the process :

viewtopic.php?f=44&t=730014&p=812483&hi ... ES#p812483

also you might want to try this process too:

viewtopic.php?f=41&t=730080&p=812767&hi ... ES#p812767

all the credit to the outstanding work of Amos Batto.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]