cancel
Showing results for 
Search instead for 
Did you mean: 

Change form in a Activiti Worklfow

dranakan
Champ on-the-rise
Champ on-the-rise
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.
3 REPLIES 3

dranakan
Champ on-the-rise
Champ on-the-rise
To get a nice start page… need to link with the process id (say in Jira : https://issues.alfresco.com/jira/browse/ALF-10112). Note : We need to keep the "activiti:formKey=" to link with the model (<startEvent id="start" name="Start" activiti:formKey="sgfwf:submitStart"></startEvent>)

In share-config-custom.xml

<config evaluator="string-compare" condition="activiti$Simple">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:assignee" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </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="other" appearance="title" label-id="workflow.set.other" />

               <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="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

I will also change the forms in the next steps in the workflows and write code here.

dranakan
Champ on-the-rise
Champ on-the-rise
I get problems to show a nice label… I have create a field ("centre") and I would to show it. The form shows "sgfwf:centre" instead of "Centre"
I have badly done something… I have add differents choice to select the good name… but all seems to be wrong… I have no messages in the logs..

models_sgfwfWorkflow.properties (and _de, _en, _fr)

prop.sgfwf_centre=Center a
worfklow.field.sgfwf_centre=Center b
sgfwf_centre=Centre  c
property.sgfwf_centre=Centre  d
sgfwf_workflowModel.property.sgfwf_centre=Centre  e
sgfwf_workflowModel.property.sgfwf_centre.title=Centre  f
sgfwf_centre.title=Centre  g

custom-slingshot-application-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <!– Add Messages –>
   <bean id="webscripts.custom.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>alfresco.module.custom.resources.models_customGeneral</value>
            <value>alfresco.module.custom.resources.models_sgfwfWorkflow</value>
         </list>
      </property>
   </bean>
</beans>

sgfWorkflow.xml

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

   <!– Optional meta-data about the model –>
   <description>Custom Workflow Model for Finance</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/finance/1.0"
         prefix="sgfwf" />
   </namespaces>

   <types>
   <type name="sgfwf:submitStart">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="sgfwf:centre">
               <type>d:int</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:genre">
               <type>d:int</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:account">
               <type>d:int</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:montant">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sgfwf:libelle">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>false</multiple>
            </property>
         </properties>
         <!–  To select a user –>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>
      <type name="sgfwf:addData">
         <parent>sgfwf:submitStart</parent>
      </type>
      <type name="sgfwf:approve">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>read_package_item_actions</default>
            </property>
         </overrides>
      </type>
   </types>
</model>


share-config-custom.xml

<!– Activiti Ad Hoc Workflow Definition –>
   <config evaluator="string-compare" condition="activiti$Simple">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="sgfwf:centre" />
               <show id="sgfwf:genre" />
               <show id="sgfwf:account" />
               <show id="sgfwf:montant" />
               <show id="sgfwf:libelle" />
               <show id="bpm:assignee" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </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="other" appearance="title" label-id="workflow.set.other" />

               <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="sgfwf:centre" set="other" label-id="sgfwf:centre" />
               <field id="sgfwf:genre" set="other" />
               <field id="sgfwf:account" set="other" />
               <field id="sgfwf:montant" set="other" />
               <field id="sgfwf:libelle" set="other" />
               <field id="bpm:status" set="progress" />>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>


What should I use in the properties files ?

Support : http://blogs.alfresco.com/wp/ddraper/2011/08/03/customizing-alfresco-share-i18n-properties/ (but can't access my custom workflow with sufbug enable)

Thank you

dranakan
Champ on-the-rise
Champ on-the-rise
The label name displayed in Share is defined in Alfresco (not in Share).

1. Specify the label file in your workflow in 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="models">
      <list>
        <value>alfresco/module/custom/model/sgfWorkflow.xml</value>
      </list>
    </property>
      <property name="labels">
         <list>
            <value>alfresco.module.custom.resources.models_sgfWorkflow</value>
         </list>
      </property>
   </bean>
2. Create the label file : models_sgfWorkflow.properties and add your properties :

# Workflow
Simple.workflow.title=Title of the Workflow
# Properties
sgfwf_workflowModel.property.sgfwf_centre.title=Center
3. In Share, in share-config-custom.xml, do not use : label-id="… Just :
<field id="sgfwf:centre" set="other" />