cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED]Conditional actor assignment

ljyanes
Champ in-the-making
Champ in-the-making
Hi, I'm working on a workflow and trying to specify to who some task will be assigned. So far I was giving it this approach, the user on the task interface selects from a list containing the different departments on the organization, then on the transition from that task (the start-task) I would map their choice to the user responsible for that department. ATM I'm getting a
org.alfresco.service.cmr.workflow.WorkflowException: 09200004 actor expression must evaluate to a person

This is the processdefinition:
<?xml version="1.0" encoding="UTF-8"?>

<process-definition  xmlns="urn:jbpm.org:jpdl-3.1"  name="cgcwf:procesoAuditoria">
  <swimlane name="initiator" />
 
  <swimlane name="Auditor">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
        <actor>#{bpm_asignee}</actor>
      </assignment>
   </swimlane>

   <swimlane name="Director">
     <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
      <actor>#{director}</actor>
    </assignment>
   </swimlane>

   <swimlane name="Contralor">
     <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
       <actor>#{contralor}</actor>
     </assignment>
   </swimlane>


   <start-state name="Inicio de la Auditoria">
      <task name="cgcwf:iniciarAuditoria" swimlane="initiator"></task>
      <transition to="Solicitud de Credenciales" name="Iniciar"></transition>
      <event type="node-leave">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
        <script>
          <variable name="director" access="write"></variable>
          <expression>
          switch(String(cgcwf_nombreDireccion).toLowerCase()){
            case "Dir. Admin Descentralizada":
              people.getPerson('adescentralizada');
            break;
            case "Dir. Admin Centralizada":
              people.getPerson('acentralizada');
            break;
            case "Dir. Control de Bienes":
              people.getPerson('cbienes');
            break;
            case "Dir. Obras Comunales":
              people.getPerson('ocomunales');
            break;
            case "Dir. Control de Gestion":
              people.getPerson('cgestion');
            break;
            case "Dir. Declaraciones Juradas":
              people.getPerson('djuradas');
            break;
            case "Dir. Determinacion de Responsabilidades":
              people.getPerson('dresponsabilidades');
            break;
            case "Dir. Tecnologia y Sistemas":
              people.getPerson('dtys');
            break;
            case "Dir. Control Educativo":
              people.getPerson('ceducativo');
            break;
          }
          </expression>
        </script>
      </action>
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
        <script>
          <variable name="contralor" access="write"></variable>
          <expression>
            people.getPerson('contralor');
          </expression>
        </script>
      </action>
    </event>
   </start-state>


   <task-node name="Solicitud de Credenciales">
      <task name="cgcwf:solicitarCredenciales" swimlane="Director"></task>
      <event type=""></event>
      <transition to="Aprobacion de Credenciales" name="Solicitar"></transition>
   </task-node>

   <task-node name="Aprobacion de Credenciales">
      <task name="cgcwf:aprobarCredenciales" swimlane="Contralor">
      </task>
      <transition to="Programación de la Auditoría" name="Aprobar"></transition>
      <transition to="Solicitud de Credenciales" name="Rechazar"></transition>
   </task-node>

   <task-node name="Acta de Requerimientos">
      <task name="cgcwf:agregarActa" swimlane="Auditor"></task>
      <transition to="Visita al Ente" name="Listo"></transition>
   </task-node>

   <task-node name="Borrador de Informe Preliminar">
      <task name="cgcwf:agregarInformePreliminar" swimlane="Auditor"></task>
      <transition to="Aprobación de Informe Preliminar" name="Solicitar"></transition>
   </task-node>

   <task-node name="Aprobación de Informe Preliminar">
      <task name="cgcwf:aprobarInformePreliminar" swimlane="Director"></task>
      <transition to="Borrador de Informe Preliminar" name="Rechazar"></transition>
      <transition to="Remisión al Ente" name="Aprobar"></transition>
   </task-node>

   <task-node name="Existen alegatos?">
      <task name="cgcwf:agregarAlegatos" swimlane="Auditor"></task>
      <transition to="Informe Definitivo" name="Continuar"></transition>
      <transition to="Incorporación de Alegatos" name="Observacion"></transition>
   </task-node>

   <task-node name="Informe Definitivo">
      <task name="cgcwf:agregarInformeDefinitivo" swimlane="Auditor"></task>
      <transition to="Aprobación de Informe Definitivo" name="Solicitar"></transition>
   </task-node>

   <task-node name="Aprobación de Informe Definitivo">
      <task name="cgcwf:aprobarInformeDefinitivo" swimlane="Contralor"></task>
      <transition to="Distribuir y Archivar Informe" name="Aprobar"></transition>
      <transition to="Informe Definitivo" name="Rechazar"></transition>
   </task-node>

   <task-node name="Incorporación de Alegatos">
      <task name="cgcwf:incorporarAlegatos" swimlane="Auditor"></task>
      <transition to="Informe Definitivo" name="Listo"></transition>
   </task-node>

   <task-node name="Programación de la Auditoría">
      <task name="cgcwf:programarAuditoria" swimlane="Auditor"></task>
      <transition to="Aprobacion del Programa" name="Listo"></transition>
   </task-node>

   <task-node name="Análisis de Información">
      <task name="cgcwf:analizarInformacion" swimlane="Auditor"></task>
      <transition to="Borrador de Informe Preliminar" name="Listo"></transition>
   </task-node>

   <task-node name="Remisión al Ente">
      <task name="cgcwf:remitirEnte" swimlane="Contralor"></task>
      <transition to="Existen alegatos?" name="Aprobar"></transition>
      <transition to="Borrador de Informe Preliminar" name="Rechazar"></transition>
   </task-node>

   <task-node name="Visita al Ente">
      <task swimlane="Auditor" name="cgcwf:visitarEnte"></task>
      <transition to="Análisis de Información" name="Listo"></transition>
   </task-node>

   <task-node name="Aprobacion del Programa">
      <transition to="Acta de Requerimientos" name="Aprobar"></transition>
      <transition to="Programación de la Auditoría" name="Rechazar"></transition>
   </task-node>


   <end-state name="Distribuir y Archivar Informe">
      <event type="node-leave">
         <action></action>
      </event>
   </end-state>


</process-definition>
4 REPLIES 4

jayjayecl
Confirmed Champ
Confirmed Champ
Hi,


<variable name="director" access="write"></variable>

This does not mean that the result of the call of people.getPerson() will be put into the variable director.

Try the following pattern :


<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
        <script>
            var contralor = people.getPerson('contralor');
            executionContext.setVariable("contralor", contralor);
        </script>
      </action>

ljyanes
Champ in-the-making
Champ in-the-making
Ok, I'll try that and come back telling if it worked. Thank you.

ljyanes
Champ in-the-making
Champ in-the-making
Thanks that worked gracefully, hope this solution helps anyone else trying to make use of Alfresco Workflows

jayjayecl
Confirmed Champ
Confirmed Champ
No problem
I'm glad I could help you.

After having struggled on many areas of Workflow design, I now have a motto :
- prefer Java Actions to script actions
- use type and aspect properties rather than "variables" and "controllers"
- executionContext's methods setVariable and getVariable are your best friends

Regards