Un foro de discusión para nuestra comunidad de hispano hablante
By alexisjavier
#789794
Hola Buenas!

Tengo un proceso que un SUPERVISOR puede reasignar el usuario asignado a una tarea (en la ventana de lista de casos de supervisor)
Tengo una variable @@TecnicoAsignadoUID

La pregunta es si al reasignar el task se puede cambiar el valor @@TecnicoAsignadoUID al UID del usuario re-asignado?

Se que en el proceso se puede ejecutar un trigger cuando haya una reasignacion, pero no se como llegar al UID del nuevo usuario.

Gracias!
Alexis,
User avatar
By amosbatto
#789798
No es posible conseguir el usuario que sera reasignado al caso en el trigger de reasignación, pero puedes crear una trigger como este para setear la variable cuando se abre el caso:
Code: Select all
//Set to ID of a task in the process where Technico is assigned:
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXXXXX';
if (@@TASK == $taskId) {
   $c = new Cases()
   $aCase = $c->LoadCase(@@APPLICATION, @%INDEX);
   @@TecnicoAsignadoUID = $aCase['CURRENT_USER_UID']; //assign user currently assigned to task
}
Puedes setear este trigger para ejecutar en "Execute a trigger when a case is opened:" en las propiedades del proceso (haz clic la derecha en tu mapa del proceso y selecciona "Edit Process" en el menu contextual que aparece).
User avatar
By amosbatto
#789801
Encontré una manera para conseguir la ID del usuario asignado en un trigger executado durante la reasignación.

The trigger for case reassignment is executed after the reassignment action, so a new delegation index has already been created and a new record has been added to the APP_DELEGATION table in the database. When the trigger is fired, @%INDEX is still set to the delegation index of the previous assigned user and @@USER_LOGGED and @@USR_USERNAME is set to the ID and username of the user who is doing the reassigning (which may be the previous assigned user who has the PM_REASSSIGNCASE permission or a process supervisor who has the PM_REASSIGNCASE_SUPERVISOR permission).

To find out who is the user newly assigned to the case, use the following database query in the APP_DELEGATION table in the trigger which is executed during reassignment:
Code: Select all
$taskId = @@TASK;
$oldIndex = @@INDEX;
$sql = "SELECT USR_UID, DEL_INDEX FROM APP_DELEGATION WHERE TAS_UID='$taskId' AND 
   DEL_THREAD_STATUS='OPEN' AND DEL_INDEX<>$oldIndex ORDER BY DEL_INDEX DESC";
$result = executeQuery($sql);
if (!is_array($result) or empty($result)) {
   throw new Exception("Error: Case reassignment failed!");
}
$newIndex = $result[1]['DEL_INDEX'];
$newUserId = $result[1]['USR_UID'];
$aUser = userInfo($newUserId);
$newUserName = $aUser['firstname'].' '.$aUser['lastname'];
$newUserEmail = $aUser['mail'];
To find out who was the previously assigned user to the case, use the Cases::LoadCase() method and the @%INDEX system variable, which is still set to the delegation index of the previous delegation:
Code: Select all
$c = new Cases();
$aCase = $c->LoadCase(@@APPLICATION, @%INDEX);
$oldUserId = $aCase['CURRENT_USER_UID'];
$oldUserName = $aCase['CURRENT_USER'];
$oldUserEmail = userInfo($oldUserId)['mail'];
#789820
[quote="amosbatto"]Encontré una manera para conseguir la ID del usuario asignado en un trigger executado durante la reasignación.

The trigger for case reassignment is executed after the reassignment action, so a new delegation index has already been created and a new record has been added to the APP_DELEGATION table in the database. When the trigger is fired, @%INDEX is still set to the delegation index of the previous assigned user and @@USER_LOGGED and @@USR_USERNAME is set to the ID and username of the user who is doing the reassigning (which may be the previous assigned user who has the PM_REASSSIGNCASE permission or a process supervisor who has the PM_REASSIGNCASE_SUPERVISOR permission).

To find out who is the user newly assigned to the case, use the following database query in the APP_DELEGATION table in the trigger which is executed during reassignment:
Code: Select all
$taskId = @@TASK;
$oldIndex = @@INDEX;
$sql = "SELECT USR_UID, DEL_INDEX FROM APP_DELEGATION WHERE TAS_UID='$taskId' AND 
   DEL_THREAD_STATUS='OPEN' AND DEL_INDEX<>$oldIndex ORDER BY DEL_INDEX DESC";
$result = executeQuery($sql);
if (!is_array($result) or empty($result)) {
   throw new Exception("Error: Case reassignment failed!");
}
$newIndex = $result[1]['DEL_INDEX'];
$newUserId = $result[1]['USR_UID'];
$aUser = userInfo($newUserId);
$newUserName = $aUser['firstname'].' '.$aUser['lastname'];
$newUserEmail = $aUser['mail'];
Impecable!!! Muchas Gracias Amos!!

Tuve que modificar la query para que filtre por @@APLICATION porque si tenes mas de un caso abierto tomaba el ultimo
Code: Select all
$taskId = @@TASK;
$oldIndex = @@INDEX;
$appUID = @@APPLICATION;

$sql = "SELECT USR_UID, DEL_INDEX FROM APP_DELEGATION WHERE TAS_UID='$taskId' AND 
   DEL_THREAD_STATUS='OPEN' AND DEL_INDEX<>$oldIndex AND APP_UID='$appUID' ORDER BY DEL_INDEX DESC";

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]