AnsweredAssumed Answered

Change form in a Activiti Worklfow

Question asked by dranakan on Nov 2, 2011
Latest reply on Nov 17, 2011 by dranakan
Hello,

I'am trying to create a Workflow with Activiti. I can deploy the new Workflow but I need help to change the forms… When I start the new Workflow, the begin page is always the same (https://issues.alfresco.com/jira/secure/attachment/24727/adhoc+activiti.png). My goal is to change this first page.

I have done :

1. In my AMP module for Alfresco : Creation of the Worfklow with Eclipse (Simple.bpmn20.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="Simple" name="Adhoc Activiti TestProcess">
    <startEvent id="start" name="Start" activiti:formKey="sgwf:submitStart"></startEvent>
    <userTask id="adhocTask" name="Adhoc Task" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:adhocTask">
      <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);</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed." activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:completedAdhocTask">
      <documentation>
                Verify the arbitrary task was completed.
            </documentation>
      <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;

if (wf_notifyMe)
{
var mail = actions.create("mail");
mail.parameters.to = initiator.properties.email;
mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
mail.parameters.from = bpm_assignee.properties.email;
mail.parameters.text = "It's done";
mail.execute(bpm_package);</activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <endEvent id="theEnd" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="start" targetRef="adhocTask"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="adhocTask" targetRef="verifyTaskDone"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="verifyTaskDone" targetRef="theEnd"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Simple">
    <bpmndi:BPMNPlane bpmnElement="Simple" id="BPMNPlane_Simple">
      <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
        <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="adhocTask" id="BPMNShape_adhocTask">
        <omgdc:Bounds height="55" width="105" x="105" y="190"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="verifyTaskDone" id="BPMNShape_verifyTaskDone">
        <omgdc:Bounds height="55" width="105" x="250" y="190"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="theEnd" id="BPMNShape_theEnd">
        <omgdc:Bounds height="35" width="35" x="395" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
        <omgdi:waypoint x="105" y="217"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="210" y="217"></omgdi:waypoint>
        <omgdi:waypoint x="250" y="217"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="355" y="217"></omgdi:waypoint>
        <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


2.  In my AMP module for Alfresco : Deploy the workflow (workflow-context.xml)


   <bean id="simple.custom.workflowBootstrap" parent="workflowDeployer">
      <property name="workflowDefinitions">
         <list>
            <props>
               <prop key="engineId">activiti</prop>
               <prop key="location">alfresco/module/custom/workflow/financial/simple/Simple.bpmn20.xml</prop>
               <prop key="mimetype">text/xml</prop>
               <prop key="redeploy">true</prop>
            </props>
         </list>
      </property>
      <property name="labels">
         <list>
            <value>alfresco.module.custom.resources.wf_custom</value>
         </list>
      </property>
   </bean>
</beans>
3. In my AMP module for Alfresco : Creation of the model (customWorkflow.xml):

<?xml version="1.0" encoding="UTF-8"?>
   <!– Definition of a Workflow –>
<model name="sgwf:workflowModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Custom Workflow Model</description>
   <author>Custom </author>
   <version>1.0</version>

   <!–
      Imports are required to allow references to definitions in other
      models
   –>
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0"
         prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.Custom.ch/model/workflow/1.0"
         prefix="sgwf" />
   </namespaces>

   <types>
      <type name="sgwf:submitStart">
         <parent>bpm:startTask</parent>
         <!–  To select a user –>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

      <type name="sgwf:approve">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>read_package_item_actions</default>
            </property>
         </overrides>
      </type>
   </types>
</model>

4. In my AMP module for Share : Add new form (share-config-custom.xml)


    <config evaluator="task-type" condition="sgwf:submitStart">
      <forms>
         <form id="workflow-details">
            <field-visibility>
               <show id="bpm:sendEMailNotifications" />
               <show id="packageItems" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.workflow.more_info" />
               <set id="items" appearance="title" label-id="workflow.set.items" />

               <field id="packageItems" set="items" />
            </appearance>
         </form>

         <form>
            <field-visibility>
               <!– <show id="message" />–>
               <show id="taskOwner" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:taskId" />
               <!–  <show id="bpm:status" />–>
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.task.info" />
               <set id="info" appearance="" template="/org/alfresco/components/form/3-column-set.ftl" />
               <set id="progress" appearance="title" label-id="workflow.set.task.progress" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="other" appearance="title" label-id="workflow.set.other" />

               <field id="message">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="taskOwner" set="info" />
               <field id="bpm:taskId" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info" read-only="true">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="bpm:status" set="progress" />
               <field id="bpm:sendEMailNotifications" set="other" />
               <field id="packageItems" set="items" />
            </appearance>
         </form>
      </forms>
   </config>
</alfresco-config>

5. Deploy the module in Alfresco.


I have done the link to catch the form with "sgwf:submitStart" (in the workflow, model and form).
I have set to debug the log4j.logger.org.alfresco.repo.activities=debug and log4j.logger.org.alfresco.repo.workflow=debug
, but I have no relevant messages in the logs.

What is wrong ?
My model was done from a sample for bpm… Do I change it ?

(Alfresco 4.0b / Mysql, Rhel 5.6)

https://issues.alfresco.com/jira/browse/ALF-10112

Thank you.

Outcomes