cancel
Showing results for 
Search instead for 
Did you mean: 

trying to work with 2 assignes in different tasks

cjimenez2581
Champ in-the-making
Champ in-the-making
hello people,
Im trying to create a workflow that for every task I can change the person ( assigne )
I have 2 task… see the code:
share-config-custom.xml
<config evaluator="task-type" condition="ak:tareaRevisar">
         <forms>
       <form>
          <field-visibility>
             <show id="bpm:workflowDescription" />
             <show id="packageItems" />
             <show id="ak:reviewOutcome" />
         <show id="ak:publicador"/>
                     <show id="transitions" />
         <hide id="ak:mail1" />
         <hide id="ak:mail2" />
          </field-visibility>
          <appearance>
             <set id="" appearance="title" label-id="workflow.set.general" />
             <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
             <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
             <set id="items" appearance="title" label-id="workflow.set.items" />
             <set id="response" appearance="title" label-id="workflow.set.response" />
                      <field id="ak:publicador" label-id="workflow.field.publicador" set="assignee" />
             <field id="bpm:workflowDescription" label-id="workflow.field.message">
                <control template="/org/alfresco/components/form/controls/textarea.ftl">
                   <control-param name="style">width: 95%</control-param>
                </control>
             </field>
             <field id="packageItems" set="items" />
             <field id="transitions" set="response" />              
          </appearance>
       </form>
         </forms>
    </config>
   
   <config evaluator="task-type" condition="ak:tareaPublicar">
         <forms>
       <form>
          <field-visibility>
             <show id="bpm:workflowDescription" />
          <show id="ak:estadoPublicacion" />
      <!–       <show id="packageItems" />  –>
                     <show id="transitions" />
          </field-visibility>
          <appearance>
             <set id="" appearance="title" label-id="workflow.set.general" />
             <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
            <!– <set id="assignee" appearance="title" label-id="workflow.set.assignee" /> –>
           <!–  <set id="items" appearance="title" label-id="workflow.set.items" /> –>
             <set id="response" appearance="title" label-id="workflow.set.response" />
                 <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="packageItems" set="items" />
               <field id="transitions" set="response" />        
          </appearance>
       </form>
         </forms>
    </config>

modelo.xml
<types>
      <type name="ak:InicioPublicacion">
         <parent>bpm:startTask</parent>
          <mandatory-aspects>
                <aspect>bpm:assignee</aspect>
          </mandatory-aspects>
      </type>
      <type name="ak:tareaRevisar">
         <parent>bpm:activitiOutcomeTask</parent>
                  <properties>
            <property name="ak:mail1">
               <type>d:text</type>
            </property>
            <property name="ak:mail2">
               <type>d:text</type>
            </property>
                         <property name="ak:reviewOutcome">
                          <type>d:text</type>
                          <default>Rechazar</default>
                   <constraints>
                       <constraint type="LIST">
                           <parameter name="allowedValues">
                               <list>
                                   <value>Rechazar</value>
                                   <value>Aprobar</value>
                               </list>
                           </parameter>
                        </constraint>
                  </constraints>
                         </property>
                  </properties>
         <mandatory-aspects>
                     <aspect>ak:publicador</aspect>
               </mandatory-aspects>
      </type>
      <type name="ak:tareaPublicar">
         <parent>bpm:activitiOutcomeTask</parent>
                  <properties>
            <property name="ak:estadoPublicacion">
                <type>d:text</type>
                <default>Publicar</default>
                   <constraints>
                       <constraint type="LIST">
                   <parameter name="allowedValues">
                       <list>
                           <value>Publicar</value>
                           <value>No publicar</value>
                       </list>
                   </parameter>
                        </constraint>
                  </constraints>
                    </property>
                  </properties>
      </type>
</types>
<aspects>
    <aspect name="ak:publicador">
       <associations>
      <association name="ak:publicador">
          <source>
         <mandatory>true</mandatory>
         <many>false</many>
          </source>
          <target>
         <class>cm:person</class>
         <mandatory>true</mandatory>
         <many>false</many>
          </target>
      </association>
       </associations>
   </aspect>
</aspects>

process.xml

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">

<process id="ProcesoPublicar" name="Review And Approve Activiti Process">

    <startEvent id="eventoInicio" name="Inicio" activiti:formKey="ak:InicioPublicacion"></startEvent>

    <userTask id="tarea1" name="Tarea Revisar" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="ak:tareaRevisar">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>execution.setVariable('ak_reviewOutcome', task.getVariable('ak_reviewOutcome'));</activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>
      execution.setVariable('ak_mail1', initiator.properties.email);
      execution.setVariable('ak_mail2', bpm_assignee.properties.email);
</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>

    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="eventoInicio" targetRef="tarea1"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow2" name="" sourceRef="tarea1" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow8" name="" sourceRef="exclusivegateway1" targetRef="endevent1">
      <extensionElements>
        <activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
          <activiti:field name="script">
            <activiti:string>
      var mail = actions.create("mail");
      mail.parameters.to = ak_mail1;
      mail.parameters.subject = "Estado de la Publicacion";
      mail.parameters.from = ak_mail2;
      mail.parameters.text = "Lo sentimos, pero su articulo no fue aprobado";
      mail.execute(bpm_package);
      </activiti:string>
          </activiti:field>
        </activiti:executionListener>
      </extensionElements>
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ak_reviewOutcome == 'Rechazar'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="tarea2" name="Tarea Publicar" activiti:assignee="${ak_publicador.properties.userName}" activiti:formKey="ak:tareaPublicar">
    </userTask>
    <sequenceFlow id="flow9" name="" sourceRef="exclusivegateway1" targetRef="tarea2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${ak_reviewOutcome == 'Aprobar'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow10" name="" sourceRef="tarea2" targetRef="endevent1">
      <extensionElements>
        <activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
          <activiti:field name="script">
            <activiti:string>
      var mail = actions.create("mail");
      mail.parameters.to = ak_mail1;
      mail.parameters.to_many =  ak_mail2;
      mail.parameters.from = ak_publicador.properties.mail;
      mail.parameters.subject = "Estado de la Publicacion";
      if(ak_estadoPublicacion == 'Publicar')
      {
         mail.parameters.text = "Su articulo fue publicado";
      }
      else
      {
         mail.parameters.text = "Su articulo no ha sido publicado";
      }
      mail.execute(bpm_package);
        </activiti:string>
          </activiti:field>
        </activiti:executionListener>
      </extensionElements>
    </sequenceFlow>
  </process>
</definitions>

and the error that I obtained from catalina.out is:
 at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282)
        at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
        at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:383)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
        at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'ak_publicador'
        at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
        at org.activiti.engine.impl.juel.AstProperty.eval(AstProperty.java:52)
        at org.activiti.engine.impl.juel.AstProperty.eval(AstProperty.java:52)
        at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)

I hope you can give me some ideas or much better, solutions  Smiley Happy

Thanks you!
4 REPLIES 4

yaziderman
Champ in-the-making
Champ in-the-making
I am facing such a problem, will anyone help us?!

granddams
Champ in-the-making
Champ in-the-making
Hi,

Log tels you that "ak_publicador" doesn't exist in your task "tarea2". Indeed, in your model you've not defined this aspect in your type "ak:tareaPublicar".
I don't know if i've made a mistake when i told you in my previous post (http://forums.alfresco.com/en/viewtopic.php?f=34&t=38582) that you should place your assignee's aspects in the same file after your types in the model.xml

If i well understand you, you want:
* an A startTask where you define two diferents assignees
* a B task where first assignee (for instance bpm_assignee if you want) is called to validate the task
* a C task where second assignee (for instance ak_publicador) is called to validate the task

So you've to modify your startTask in your process-definition.xml such as:
<startEvent id="eventoInicio" name="Inicio" activiti:formKey="ak:InicioPublicacion">
     <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>
                 execution.setVariable('ak_wf_publicador', task.getVariable('ak_publicador'));
            </activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
</startEvent>



<userTask id="tarea2" name="Tarea Publicar" activiti:assignee="${ak_wf_publicador.properties.userName}" activiti:formKey="ak:tareaPublicar"></userTask>

and for your modelo.xml try:
<types>
      <type name="ak:InicioPublicacion">
         <parent>bpm:startTask</parent>
          <mandatory-aspects>
                <aspect>bpm:assignee</aspect>
                <aspect>ak:publicador</aspect>
          </mandatory-aspects>
      </type>

     <type name="ak:tareaRevisar">
         <parent>bpm:activitiOutcomeTask</parent>
         <properties>
            <property name="ak:mail1">
               <type>d:text</type>
            </property>
            <property name="ak:mail2">
               <type>d:text</type>
            </property>
             <property name="ak:reviewOutcome">
               <type>d:text</type>
               <default>Rechazar</default>
                <constraints>
                       <constraint type="LIST">
                           <parameter name="allowedValues">
                               <list>
                                   <value>Rechazar</value>
                                   <value>Aprobar</value>
                               </list>
                           </parameter>
                        </constraint>
                 </constraints>
             </property>
         </properties>
        
        <!– You don't need ak:publicador here if i well understand you–>
     </type>

    <type name="ak:tareaPublicar">
         <parent>bpm:activitiOutcomeTask</parent>
         <properties>
            <property name="ak:estadoPublicacion">
                <type>d:text</type>
                <default>Publicar</default>
                <constraints>
                   <constraint type="LIST">
                   <parameter name="allowedValues">
                       <list>
                           <value>Publicar</value>
                           <value>No publicar</value>
                       </list>
                   </parameter>
                   </constraint>
                 </constraints>
              </property>
         </properties>
    </type>
</types>

<aspects>
    <aspect name="ak:publicador">
       <associations>
          <association name="ak:publicador">
             <source>
                <mandatory>true</mandatory>
                <many>false</many>
             </source>
             <target>
               <class>cm:person</class>
               <mandatory>true</mandatory>
               <many>false</many>
            </target>
         </association>
      </associations>
   </aspect>
</aspects>

And of caurse, you've to show the two fields for assignees in your startTask:
<config evaluator="task-type" condition="ak:InicioPublicacion">
        <forms>
       <form>
          <field-visibility>
             <show id="bpm:workflowDescription" />
             <show id="packageItems" />
             <show id="ak:publicador"/>
             <show id="bpm:assignee" />
             <show id="transitions" />
          </field-visibility>
          <appearance>
             <set id="" appearance="title" label-id="workflow.set.general" />
             <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
             <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
             <set id="items" appearance="title" label-id="workflow.set.items" />
             <set id="response" appearance="title" label-id="workflow.set.response" />

             <field id="ak:publicador" label-id="workflow.field.publicador" set="assignee1" />
             <field id="bpm:assignee" label-id="workflow.field.publicador" set="assignee2" />
             <field id="bpm:workflowDescription" label-id="workflow.field.message">
                <control template="/org/alfresco/components/form/controls/textarea.ftl">
                   <control-param name="style">width: 95%</control-param>
                </control>
             </field>
             <field id="packageItems" set="items" />
             <field id="transitions" set="response" />              
          </appearance>
       </form>
      </forms>
    </config>



Am i clearer?

cjimenez2581
Champ in-the-making
Champ in-the-making
I dont need to assigne 'ak_publicador'  in first task but second task ( tarea2 )

but Ill try your ideas
thanks

nunut
Champ in-the-making
Champ in-the-making
Hai cjimenez2581

Did you solve this problem??Could you explain the answer?I'm facing same problem too.