Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#815355
Departments in ProcessMaker may only have one manager and users can only be members of one department.

If you need something different, then you should create a PM Table that holds your department information and use Value Based Assignment instead of the "Reports to" assignment rule and use database queries in triggers to get the managers and members of the departments.
#815444
You can figure out how to best store the department information in PM Tables. What I would do is create the following two tables:
PMT_DEPARTMENTS:
1. DPT_ID, char(32)
2. DPT_NAME, char(64)
3. DPT_PARENT_ID, char(32), (only set if the department is a subdepartment of another department)

PMT_DEPARTMENT_MEMBERS:
1. DPT_ID, char(32)
2. MBR_ID, char(32), (You can set this to the same ID used by ProcessMaker users. See the USERS.USR_UID field in the database.)
3. MBR_USERNAME, char(50)
4. MBR_FIRST_NAME, char(64)
5. MBR_LAST_NAME, char(64)
6. IS_MANAGER, int(1), (set to 1 if manager or 0 if not a manager of the department)


Then, your trigger code to look up the manager(s) of the current logged-in user would be:
Code: Select all
@=managers = array();
$userId = @@USER_LOGGED;
$sql = "SELECT * FROM PMT_DEPARTMENT_MEMBERS WHERE MBR_ID = '$userId'";
$result = executeQuery($sql); 
if (!empty($result)) {
    $departmentId = $result[1]['DPT_ID'];
    $sql2 = "SELECT * FROM PMT_DEPARTMENT_MEMBERS WHERE DPT_ID = '$departmentId' AND IS_MANAGER=1";
    $result2 = executeQuery($sql2);
    foreach ($result2 as $manager) {
        @=managers[] = $manager['MBR_ID'];
        //another alternative is to do this if you need more information:
        //@=managers[] = userInfo( $manager['MBR_ID'] );
    }
}
// now @@managers can be the variable used in Self Service Value Based Assignment or 
//the variable for Value Based Assignment in a task with a parallel marker 
#815994
Saludos Amos,

Me fui con la opción de 3 departamentos para cubrir los turnos pero ahora tengo una situación con la regla de asignación y es que dependiendo de la cantidad de la requisición va a depender de quien tenga que evaluar la misma.

Tengo creado una tarea para cada rango de aprobación, cada una asignada por grupos de supervisores ($1.00 - $5,000.00), gerentes($5,001 - $25,000.00) y directores ($25,001.00 - $200,000.00), también tengo configurado a los usuarios por departamentos con sub departamentos y gerente si es el caso.

Haciendo pruebas, cuando trabajo una requisición para que sea aprobada por el director del departamento, una vez sometida la misma pasa a la tarea correspondiente pero el usuario atender la misma es el gerente del sub departamento.
#815995
Si tu pregunta es cómo conseguir el gerente del departmento cuando tienes esta estructura:
Gerente-> subgerente -> usuario del departmento

Si el usuario es asignado al a tarea actual y quieres que el gerente sea asignado a la próxima tarea, puedes usar este trigger para conseguir la ID del gerente:
Code: Select all
$aUser = userInfo(@@USER_LOGGED);
if (empty($aUser['reportsto'])) {
   throw new Exception("User ".@@USR_USERNAME." needs to be assigned to a department.");
}

$aSubManager = userInfo($aUser['reportsto']);
if (empty($aSubManager['reportsto'])) {
    throw new Exception("Submanager {$aSubManager['username']} needs to be assigned to a subdepartment which has a parent department."
}

@@nextAssignedUserId = $aSubManager['reportsto']; 
Este trigger debe ejecutar before assignment en la tarea anterior.

En la tarea debes usar Value Based Assignment y la variable @@nextAssignedUserId
valueBasedAssignmentWithVar.png
valueBasedAssignmentWithVar.png (91.12 KiB) Viewed 8064 times
#817662
Debes activar Debug Mode para verificar que el valor en la variable es la ID del usuario. También debes verificar que todos los usuarios que pueden ser asignados por la variable están en la lista de asignación de la tarea.

Por ejemplo, si la variable puede tener la ID de Julio, Maria o Carmen, estos tres usuarios deben ser en la Assigned Users List de la tarea.
#817673
Saludos,

En el debug panel solamente se ve el trigger para cancelar el caso, por alguna razón no veo el trigger para la asignación de la próxima tarea.

la variable @@nextAssignedUserId debe ser creada? la que sale en pantalla por el sistema para el próximo usuario cambia.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

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