Let's say that you have the following process:
AddParticipatedUserProcess.png (6.36 KiB) Viewed 2947 times
Create the following trigger that temporarily assigns the next task to a specified user (who is also in the Ad Hoc Assignment list for the next task). Then it reassigns to the next task back to the normally assigned user.
Code: Select all//Set to the username which will participate in the case.
//Make sure that this user is in the Ad Hoc Assignment list for the
//next task in the process.
$participatedUsername = 'amos';
require_once 'classes/model/Users.php';
$u = new Users();
$aUserInfo = $u->loadByUsernameInArray($participatedUsername);
if (!is_array($aUserInfo) or empty($aUserInfo)) {
throw new Exception("User '$participatedUsername' does not exist.");
}
$participatedUserId = $aUserInfo['USR_UID'];
//look up details about the next task of the current case in the database:
$caseId = @@APPLICATION;
$sql = "SELECT * FROM APP_DELEGATION WHERE APP_UID='$caseId' ORDER BY DEL_INDEX DESC";
$aTasks = executeQuery($sql);
$nextUserId = $aTasks[1]['USR_UID'];
$nextIndex = $aTasks[1]['DEL_INDEX'];
//reassign case to $participatedUserId
$c = new Cases();
$c->reassignCase($caseId, $nextIndex, $nextUserId, $participatedUserId);
//reassign case back to $nextUserId:
$c->reassignCase($caseId, $nextIndex + 1, $participatedUserId, $nextUserId);
Set this trigger to fire
after routing in Task 1:
AddParticipatedUserSetTrigger.png (35.9 KiB) Viewed 2947 times
Make sure to fire the trigger
after routing, so that the SQL query will always get the most recent routed task in APP_DELEGATION. Otherwise, you will need to specify the ID of the task when querying the APP_DELEGATION table.
Now the user specified in the $participatedUsername will be able to see the case when he/she goes to to
Home > Participated.
Here is a sample process so that you test it:
(29.49 KiB) Downloaded 314 times