AnsweredAssumed Answered

workflow-details form does not work [SOLVED]

Question asked by jmuras on Feb 15, 2013
Latest reply on Feb 18, 2013 by jmuras
Hi,

I have problem with display of workflow details using workflow-details form. I created the following workflow:

<blockcode>

<?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://alfresco.org">

    <process id="icmrSubmissionWorkflow" name="ICMR Artefact Submission Process" isExecutable="true">

        <startEvent id="start" activiti:formKey="icmrWf:submitArtefactTask"></startEvent>

        <sequenceFlow id="flow1" sourceRef="start" targetRef="reviewTask"></sequenceFlow>

        <userTask id="reviewTask" name="Review Task" activiti:formKey="icmrWf:reviewTask">
            <extensionElements>

                <!– Set canditate group for the task –>
                <activiti:taskListener event="create" class="ie.icmr.tacitknowledge.CandidateListener" />

                <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                    <activiti:field name="script">
                        <activiti:string>
                            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('icmrWf_reviewOutcome', task.getVariable('icmrWf_reviewOutcome'));
                        </activiti:string>
                    </activiti:field>
                </activiti:taskListener>

            </extensionElements>

        </userTask>

        <sequenceFlow id="flow2" sourceRef="reviewTask" targetRef="reviewDecision"></sequenceFlow>

        <exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>

        <sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
            <conditionExpression xsi:type="tFormalExpression"><![CDATA[${icmrWf_reviewOutcome == 'Approve'}]]></conditionExpression>
        </sequenceFlow>

        <sequenceFlow id="flow4" sourceRef="reviewDecision" targetRef="rejected"></sequenceFlow>

        <userTask id="approved" name="Document Approved" activiti:assignee="${initiator.exists() ? initiator.properties.userName : 'admin'}" activiti:formKey="icmrWf:approvedTask">
            <documentation>The document was reviewed and approved.</documentation>
            <extensionElements>

                <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                    <activiti:field name="script">
                        <activiti:string>
                            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('bpm_assignee', person);
                        </activiti:string>
                    </activiti:field>
                </activiti:taskListener>

            </extensionElements>
        </userTask>

        <userTask id="rejected" name="Document Rejected" activiti:assignee="${initiator.exists() ? initiator.properties.userName : 'admin'}" activiti:formKey="icmrWf:rejectedTask">
            <documentation>The document was reviewed and rejected.</documentation>
            <extensionElements>

                <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                    <activiti:field name="script">
                        <activiti:string>
                            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('bpm_assignee', person);
                        </activiti:string>
                    </activiti:field>
                </activiti:taskListener>

            </extensionElements>
        </userTask>

        <sequenceFlow id="flow5" sourceRef="approved" targetRef="end"></sequenceFlow>

        <sequenceFlow id="flow6" sourceRef="rejected" targetRef="end"></sequenceFlow>

        <endEvent id="end"></endEvent>

        <boundaryEvent id="timer" name="Timer" attachedToRef="reviewTask" cancelActivity="true">
            <timerEventDefinition>
                <!– Fire remainder every monday at 8 am –>
                <!–<timeCycle>0 0 8 ? * MON</timeCycle>–>
                <!–<timeCycle>0 * * ? * *</timeCycle>–>
                <timeDuration>PT2M</timeDuration>
            </timerEventDefinition>
        </boundaryEvent>

        <serviceTask id="mailtask" name="Email Reminder" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
            <extensionElements>
                <activiti:field name="script">
                    <activiti:string>
                        logger.log("Send e-mail");
                    </activiti:string>
                </activiti:field>
            </extensionElements>
        </serviceTask>

        <sequenceFlow id="flow7" sourceRef="timer" targetRef="mailtask"></sequenceFlow>

        <sequenceFlow id="flow8" sourceRef="mailtask" targetRef="reviewDecision"></sequenceFlow>

    </process>

    <bpmndi:BPMNDiagram id="BPMNDiagram_icmrSubmissionWorkflow">
        <bpmndi:BPMNPlane bpmnElement="icmrSubmissionWorkflow" id="BPMNPlane_icmrSubmissionWorkflow">
            <bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
                <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="200.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="reviewTask" id="BPMNShape_reviewTask">
                <omgdc:Bounds height="55.0" width="105.0" x="180.0" y="189.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="reviewDecision" id="BPMNShape_reviewDecision">
                <omgdc:Bounds height="40.0" width="40.0" x="570.0" y="196.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="approved" id="BPMNShape_approved">
                <omgdc:Bounds height="55.0" width="105.0" x="680.0" y="96.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="rejected" id="BPMNShape_rejected">
                <omgdc:Bounds height="55.0" width="105.0" x="680.0" y="295.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
                <omgdc:Bounds height="35.0" width="35.0" x="845.0" y="199.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="timer" id="BPMNShape_timer">
                <omgdc:Bounds height="30.0" width="30.0" x="250.0" y="229.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="mailtask" id="BPMNShape_mailtask">
                <omgdc:Bounds height="55.0" width="105.0" x="212.0" y="296.0"></omgdc:Bounds>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
                <omgdi:waypoint x="65.0" y="217.0"></omgdi:waypoint>
                <omgdi:waypoint x="180.0" y="216.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
                <omgdi:waypoint x="285.0" y="216.0"></omgdi:waypoint>
                <omgdi:waypoint x="570.0" y="216.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
                <omgdi:waypoint x="590.0" y="196.0"></omgdi:waypoint>
                <omgdi:waypoint x="590.0" y="123.0"></omgdi:waypoint>
                <omgdi:waypoint x="680.0" y="123.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
                <omgdi:waypoint x="590.0" y="236.0"></omgdi:waypoint>
                <omgdi:waypoint x="590.0" y="323.0"></omgdi:waypoint>
                <omgdi:waypoint x="680.0" y="322.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
                <omgdi:waypoint x="785.0" y="123.0"></omgdi:waypoint>
                <omgdi:waypoint x="862.0" y="123.0"></omgdi:waypoint>
                <omgdi:waypoint x="862.0" y="199.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
                <omgdi:waypoint x="785.0" y="322.0"></omgdi:waypoint>
                <omgdi:waypoint x="862.0" y="323.0"></omgdi:waypoint>
                <omgdi:waypoint x="862.0" y="234.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
                <omgdi:waypoint x="317.0" y="323.0"></omgdi:waypoint>
                <omgdi:waypoint x="589.0" y="322.0"></omgdi:waypoint>
                <omgdi:waypoint x="590.0" y="236.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
                <omgdi:waypoint x="265.0" y="259.0"></omgdi:waypoint>
                <omgdi:waypoint x="264.0" y="296.0"></omgdi:waypoint>
            </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
</definitions>

</blockcode>


For the workflow I defined the following model:

<blockcode>

<?xml version="1.0" encoding="UTF-8"?>

<model name="icmrWf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <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>

    <namespaces>
        <namespace uri="http://www.alfresco.org/model/icmrWorkflow/1.0" prefix="icmrWf"/>
    </namespaces>

    <types>

        <!–  Submit task to multiple people (as included in a group) –>
        <type name="icmrWf:submitArtefactTask">
            <parent>bpm:startTask</parent>
            <properties>
                <property name="icmrWf:workgroup">
                    <type>d:text</type>
                </property>
            </properties>
            <mandatory-aspects>
                <aspect>bpm:groupAssignee</aspect>
            </mandatory-aspects>
        </type>

        <type name="icmrWf:reviewTask">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="icmrWf:reviewOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint name="icmrWf:reviewOutcomeOptions" type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>edit_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{http://www.alfresco.org/model/icmrWorkflow/1.0}reviewOutcome</default>
                </property>
            </overrides>
        </type>

        <type name="icmrWf:approvedTask">
            <parent>bpm:workflowTask</parent>
            <mandatory-aspects>
                <aspect>bpm:assignee</aspect>
            </mandatory-aspects>
        </type>

        <type name="icmrWf:rejectedTask">
            <parent>bpm:workflowTask</parent>
            <mandatory-aspects>
                <aspect>bpm:assignee</aspect>
            </mandatory-aspects>
        </type>


    </types>

</model>

</blockcode>

and forms

<blockcode>

    <config evaluator="string-compare" condition="activiti$icmrSubmissionWorkflow">
        <forms>
            <form>
                <field-visibility>
                    <show id="bpm:workflowDescription" />
                    <show id="bpm:workflowPriority" />
                    <show id="icmrWf:workgroup" />
                    <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="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="icmrWf:workgroup" label-id="workflow.field.workgroup">
                        <control template="/org/alfresco/components/form/controls/textarea.ftl">
                            <control-param name="style">width: 95%</control-param>
                        </control>
                    </field>
                    <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                        <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
                    </field>
                    <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>



    <config evaluator="task-type" condition="icmrWf:reviewTask">
        <forms>

            <form id="workflow-details">
                <field-visibility>
                    <show id="bpm:groupAssignee" />
                    <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="bpm:groupAssignee" label-id="workflow.field.review_group" />
                    <field id="packageItems" set="items" />
                </appearance>
            </form>

            <form>
                <field-visibility>
                    <show id="message" />
                    <show id="taskOwner" />
                    <show id="bpm:priority" />
                    <show id="bpm:taskId" />
                    <show id="bpm:status" />
                    <show id="packageItems" />
                    <show id="bpm:comment" />
                    <show id="icmrWf:reviewOutcome" />
                </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="response" appearance="title" label-id="workflow.set.response" />

                    <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:priority" set="info" read-only="true">
                        <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
                    </field>
                    <field id="bpm:status" set="progress" />
                    <field id="packageItems" set="items" />
                    <field id="bpm:comment" label-id="workflow.field.comment" set="response">
                        <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                    </field>
                    <field id="icmrWf:reviewOutcome" label-id="workflow.field.outcome" set="response">
                        <control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
                    </field>
                </appearance>
            </form>
        </forms>
    </config>


    <config evaluator="task-type" condition="icmrWf:approvedTask">
        <forms>

            <form>
                <field-visibility>
                    <show id="message" />
                    <show id="taskOwner" />
                    <show id="bpm:priority" />
                    <show id="bpm:taskId" />
                    <show id="bpm:status" />
                    <show id="packageItems" />
                    <show id="bpm:comment" />
                    <show id="transitions" />
                </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="response" appearance="title" label-id="workflow.set.response" />

                    <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:priority" set="info" read-only="true">
                        <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
                    </field>
                    <field id="bpm:status" set="progress" />
                    <field id="packageItems" set="items" />
                    <field id="bpm:comment" label-id="workflow.field.comment" set="response">
                        <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                    </field>
                    <field id="transitions" set="response" />
                </appearance>
            </form>
        </forms>
    </config>

    <config evaluator="task-type" condition="icmrWf:rejectedTask">
        <forms>

            <form>
                <field-visibility>
                    <show id="message" />
                    <show id="taskOwner" />
                    <show id="bpm:priority" />
                    <show id="bpm:taskId" />
                    <show id="bpm:status" />
                    <show id="packageItems" />
                    <show id="bpm:comment" />
                    <show id="transitions" />
                </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="response" appearance="title" label-id="workflow.set.response" />

                    <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:priority" set="info" read-only="true">
                        <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
                    </field>
                    <field id="bpm:status" set="progress" />
                    <field id="packageItems" set="items" />
                    <field id="bpm:comment" label-id="workflow.field.comment" set="response">
                        <control template="/org/alfresco/components/form/controls/textarea.ftl" />
                    </field>
                    <field id="transitions" set="response" />
                </appearance>
            </form>
        </forms>
    </config>

</blockcode>


After I start the workflow and I am in icmrWf:reviewTask. When I try to view workflow details somehow <form id="workflow-details"> is not detected and I get all the variables on the form.

Did someone have similar issue? Any ideas what might be wrong?

I would appreciate suggestions.

Regards,
Joanna Muras

Outcomes