Oh, you aren't talking about changing the definition of a task. Instead, you are talking about routing a case from any task to any other task in the process. You just have to close the present task in the APP_DELEGATION and APP_CACHE_VIEW tables and create new records for the task in those same tables for the task where you want the case to go.
Code: Select all$processId = 'XXXXXXXXXXXXXXXXXXXXXXXX'; //set to ID of process
$caseId = 'XXXXXXXXXXXXXXXXXXXXXXXX'; //set to the ID of the case
$currentIndex = 2; //set to the current delegation index of the case
$nextTaskId = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to ID of task where the case will be redirected
$nextUserId = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'; //set to the ID of a user who is in the task's assignment pool
$now = date("Y-m-d H:i:s");
$t = new Task();
$aTask = $t->Load($nextTaskId);
$duration = $aTask['TAS_DURATION'];
$timeUnits = $aTask['TAS_TIMEUNIT'];
$taskType = $aTask['TAS_TYPE'];
$taskTitle = $aTask[["TAS_TITLE"]:
G::LoadClass('dates');
$d = new dates();
$ret = $d->calculateDate($now, $duration, $timeUnits, 2, $nextUserId, $processId, $taskId);
$dueDate = $ret['DUE_DATE'];
executeQuery("UPDATE APP_DELEGATION SET DEL_THREAD_STATUS='CLOSED', DEL_FINISH_DATE='$now'
WHERE APP_UID='$caseId' AND DEL_INDEX=$currentIndex");
executeQuery("UPDATE APP_CACHE_VIEW SET DEL_THREAD_STATUS='CLOSED', DEL_FINISH_DATE='$now'
WHERE APP_UID='$caseId' AND DEL_INDEX=$currentIndex");
executeQuery("UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='$caseId' ");
$aCase = executeQuery("SELECT * FROM APP_CACHE_VIEW WHERE APP_UID='$caseId' AND DEL_INDEX=$currentIndex");
$nextDelegationId = $aCase[1]['DELEGATION_ID'] + 1;
$caseNo = $aCase[1]['APP_NUMBER'];
$nextIndex = $currentIndex + 1;
$thread = $aCase[1]['DEL_THREAD'];
$lastUserId = $aCase[1]['USR_UID'];
$caseTitle = $aCase[1]['APP_TITLE'];
$processTitle = $aCase[1]['APP_PRO_TITLE'];
$lastUserName = $aCase[1]['APP_CURRENT_USER'];
$aUser = userInfo($nextUserId);
$nextUserName = $aUser['firstname'] .' '. $aUser['lastname'];
$caseStarted = $aCase[1]['APP_CREATE_DATE'];
$sql = "INSERT INTO APP_DELEGATION
(APP_UID, DEL_INDEX, DELEGATION_ID, APP_NUMBER, DEL_PREVIOUS, DEL_LAST_INDEX, PRO_UID,
TAS_UID, USR_UID, DEL_TYPE, DEL_THREAD, DEL_THREAD_STATUS, DEL_PRIORITY,
DEL_DELEGATE_DATE, DEL_INIT_DATE, DEL_FINISH_DATE, DEL_TASK_DUE_DATE,
DEL_RISK_DATE, DEL_DURATION, DEL_QUEUE_DURATION, DEL_DELAY_DURATION,
DEL_STARTED, DEL_FINISHED, DEL_DELAYED, DEL_DATA, APP_OVERDUE_PERCENTAGE,
USR_ID, PRO_ID, TAS_ID)
VALUES ('$caseId', $nextIndex, $nextDelegationId, $caseNo, $currentIndex, $currentIndex, '$processId',
'$nextTaskId', '$nextUserId', '$taskType', $thread, 'OPEN', 3,
'$now', '$now', NULL, '$dueDate',
'$dueDate', 0, 0, 0,
1, 0, 0, '', 0,
0, 0, 0)";
executeQuery($sql);
executeQuery("UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='$caseId' ");
$sql = "INSERT INTO APP_CACHE_VIEW
(APP_UID, DEL_INDEX, DEL_LAST_INDEX, APP_NUMBER, APP_STATUS, USR_UID,
PREVIOUS_USR_UID, TAS_UID, PRO_UID,
DEL_DELEGATE_DATE, DEL_INIT_DATE, DEL_FINISH_DATE, DEL_TASK_DUE_DATE, DEL_RISK_DATE,
DEL_THREAD_STATUS, APP_THREAD_STATUS, APP_TITLE, APP_PRO_TITLE, APP_TAS_TITLE,
APP_CURRENT_USER, APP_DEL_PREVIOUS_USER, DEL_PRIORITY, DEL_DURATION,
DEL_QUEUE_DURATION, DEL_DELAY_DURATION, DEL_STARTED, DEL_FINISHED, DEL_DELAYED,
APP_CREATE_DATE, APP_FINISH_DATE, APP_UPDATE_DATE, APP_OVERDUE_PERCENTAGE)
VALUES
('$caseId', $nextIndex, $currentIndex, $caseNo, 'TO_DO', '$nextUserId',
'$lastUserId', '$nextTaskId', '$processId',
'$now', '$now', NULL, '$dueDate', '$dueDate',
'OPEN', 'OPEN', '$caseTitle','$processTitle', '$taskTitle',
'$nextUserName', '$lastUserName', 3, 0,
0, 0, 0, 0, 0,
'$caseStarted', NULL, '$now', 0)";
executeQuery($sql);
At least this is the code for version 3.2. You will have to adapt it for your version of PM.