There is no easy way to do this. The easiest route is to simple cancel the case and copy its data to a new case, but that will change the case number and you won't be able to see the case history.
If you want to keep the same case, I recommend redesigning your process to have a loop back to the first task after each task in the process:
loopbackAfterEveryTask.png (11.96 KiB) Viewed 3655 times
Create a string variable in the process named "firstUser". Make the first task have Value Based Assignment and use the variable @@firstUser. Create a trigger which is set to fire before the first step in the first task with the code:
Create a string variable named "restart". For every exclusive gateway add conditions to either continue with the process or route back to the first task:
(!isset(@@restart) or @@restart != 'yes') to continue
(isset(@@restart) and @@restart == 'yes') to route to first task
routingRulesToRestart.png (23.66 KiB) Viewed 3655 times
Then, make another process with one task and a DynaForm step which displays a grid of cases that can be restarted. See this
example for the grid to create.
Create this trigger to fire before the DynaForm with the "casesList" grid:
Code: Select all$userId = @@USER_LOGGED;
$query = "SELECT DISTINCT ACV.APP_UID, ACV.DEL_INDEX, ACV.USR_UID, ACV.APP_NUMBER,
ACV.APP_PRO_TITLE, ACV.APP_TAS_TITLE, ACV.APP_CURRENT_USER, ACV.APP_UPDATE_DATE,
ACV.APP_STATUS FROM APPLICATION A, APP_CACHE_VIEW ACV
WHERE A.APP_INIT_USER='$userId' AND (A.APP_STATUS='DRAFT' OR A.APP_STATUS='TO_DO') AND
A.APP_UID=ACV.APP_UID AND ACV.DEL_THREAD_STATUS='OPEN' ORDER BY ACV.APP_NUMBER DESC ";
$aCases = executeQuery($query);
if (!is_array($aCases))
die("Error in query: $query");
@=casesList = array();
for($i = 1; $i <= count($aCases); $i++) {
@=casesList[$i] = array(
'caseId' => $aCases[$i]['APP_UID'],
'index' => $aCases[$i]['DEL_INDEX'],
'userId' => $aCases[$i]['USR_UID'],
'reopen' => '0',
'caseNo' => $aCases[$i]['APP_NUMBER'],
'process' => $aCases[$i]['APP_PRO_TITLE'],
'task' => $aCases[$i]['APP_TAS_TITLE'],
'user' => $aCases[$i]['APP_CURRENT_USER'],
'updated' => $aCases[$i]['APP_UPDATE_DATE'],
'status' => $aCases[$i]['APP_STATUS']
);
}
Then add a second trigger to fire after the DynaForm:
Code: Select allif (isset(@=casesList) and !empty(@=casesList)) {
$restartedCases = '';
foreach (@=casesList as $aCase) {
if ($aCase['reopen'] == '0') {
continue;
}
PMFSendVariables($aCase['caseId'], array('restart' => 'yes'));
PMFDerivateCase($aCase['caseId'], $aCase['index']);
PMFSendVariables($aCase['caseId'], array('restart' => 'no'));
$c = new Cases();
$aCaseInfo = $c->loadCase($aCase['caseId']);
$aCaseInfo['APP_STATUS'] = 'DRAFT';
$c->updateCase($caseId, $aCaseInfo);
$restartedCases .= (empty($restartedCases) ? '' : ', ') . $aCase['caseNo'];
}
if ($restartedCases) {
G::SendMessageText("Case(s) $restartedCases restarted.", "INFO");
}
}
I haven't tested this code, so it might require some debug, but you get the basic idea.