03-14-2018 10:09 AM
Hi,
i have the following diagram :
I have put logs to follow step by step the process :
Start :
Option 1 :
Log for option 2 :
Log for End :
The option 2 is ok :
But option 1 is never :
However Javascript (COMPLETE event) is well executed for the option 1 :
code :
Log :
But the task "Stand-by secrétaire" is never called/loaded so active task become "completed" each time i choose this option
I don't understand why ?
Thank you in advance
03-14-2018 09:47 PM
Please, share the bmpn file.
With that, it will be easier to anyone here to try to help you.
03-15-2018 04:00 AM
Of course :
<?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:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsmgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://activiti.org/bpmn20" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20" id="review-definitions" name="">
<process id="activitiValidationDocumed" name="Validation Documed" isExecutable="true" isClosed="false" processType="None">
<extensionElements>
<activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('wf_approveCount', 100);
execution.setVariable('wf_actualPercent', 100);
execution.setVariable('wf_reviewerCount', bpm_assignees.size());
execution.setVariable('wf_requiredPercent', wf_requiredApprovePercent);]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<startEvent id="start" activiti:formKey="wf:submitParallelReviewTask"></startEvent>
<sequenceFlow id="flow1" sourceRef="start" targetRef="validationSecretaire"></sequenceFlow>
<userTask id="validationSecretaire" name="Validation secrétaire" activiti:assignee="${reviewAssignee.properties.userName}" activiti:formKey="wfvd:activitiReviewTask">
<extensionElements>
<activiti:taskListener event="assignment" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;logger.log("task.getVariable(reviewAssignee) assigment : "+task.getVariable("reviewAssignee"));
logger.log("Task CREATE - formulaire principal");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
logger.log("Task COMPLETE - Before mainValidationSecretaire()");
mainValidationSecretaire();
logger.log("Task COMPLETE - After mainValidationSecretaire()");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="bpm_assignees" activiti:elementVariable="reviewAssignee">
<completionCondition>${wf_actualPercent >= wf_requiredApprovePercent}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="validationSecretaire" targetRef="reviewDecision">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("flow 2 - TAKE - execution.getVariable(wfvd_reviewOutcomeEnreg) : "+execution.getVariable('wfvd_reviewOutcomeEnreg'));
logger.log("flow 2 - TAKE - execution.getVariable(wfvd_reviewOutcomeMed) : "+execution.getVariable('wfvd_reviewOutcomeMed'));
logger.log("flow 2 - TAKE - execution.getVariable(wfvd_reviewOutcomeDel) : "+execution.getVariable('wfvd_reviewOutcomeDel'));
logger.log("flow 2 - TAKE - execution.getVariable(wfvd_reviewOutcomeDpe) : "+execution.getVariable('wfvd_reviewOutcomeDpe'));]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</sequenceFlow>
<exclusiveGateway id="reviewDecision" name="Review Decision"></exclusiveGateway>
<sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="validationMedecin">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("flow 3 - TAKE- MED");]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMed') == 'MED'}]]></conditionExpression>
</sequenceFlow>
<userTask id="validationMedecin" name="Validation Médecin" activiti:assignee="${wfvd_medecin.properties.userName}" activiti:formKey="wfvd:activitiReviewTaskMedecin">
<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><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
logger.log("CREATE - Before OncreateValidationMedecin ");
OncreateValidationMedecin();
logger.log("CREATE - After OncreateValidationMedecin ");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
logger.log("COMPLETE - Before mainValidationMedecin()");
mainValidationMedecin();
logger.log("COMPLETE - After mainValidationMedecin()");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<endEvent id="end"></endEvent>
<sequenceFlow id="flow6" sourceRef="reviewDecision" targetRef="end">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("Flow 6 - TAKE - Fin du workflow from valid secretaire");]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</sequenceFlow>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow7" sourceRef="validationMedecin" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="exclusivegateway1" targetRef="end">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMedecinDpe') == 'DPE'}]]></conditionExpression>
</sequenceFlow>
<userTask id="validationRefusSecretaire" name="Validation refus secrétaire" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wfvd:activitiReviewTaskRefusSecretaire">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
logger.log("CREATE - Validation Refus secretaire");
task.setVariable("bpm_workflowDescription",execution.getVariable("bpm_workflowDescription"));
task.setVariable("bpm_priority",execution.getVariable("bpm_priority"));
logger.log("Hello from Validation Refus Sec . create");
logger.log("CREATE - formulaire gestion des refus");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
logger.log("COMPLETE - Before mainValidationSecretaire()");
mainValidationSecretaire();
logger.log("COMPLETE - After mainValidationSecretaire()");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow9" sourceRef="exclusivegateway1" targetRef="validationRefusSecretaire">
<extensionElements>
<activiti:executionListener event="create" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("flow 9 - Renvoi secrétaire- execution.getVariable(wfvd_commentaireSecretaire)onCreate : "+execution.getVariable("wfvd_commentaireSecretaire"));
logger.log("flow 9 - Renvoi secrétaire- execution.getVariable(wfvd_commentaireMedecin)onCreate : "+execution.getVariable("wfvd_commentaireMedecin"));]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${wfvd_reviewOutcomeMedecinReturn == 'RETOUR'}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow10" sourceRef="validationRefusSecretaire" targetRef="exclusivegateway2"></sequenceFlow>
<sequenceFlow id="flow11" sourceRef="exclusivegateway2" targetRef="validationMedecin">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable("wfvd_reviewOutcomeMed") == 'MED'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow12" sourceRef="exclusivegateway2" targetRef="end"></sequenceFlow>
<exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow15" sourceRef="exclusivegateway3" targetRef="validationMedecin">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("flow 15 - TAKE - execution.getVariable(wfvd_commentaireSecretaire): "+execution.getVariable("wfvd_commentaireSecretaire"));]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeMed') == 'MED'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow16" sourceRef="exclusivegateway3" targetRef="end">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("TAKE - Fin du workflow from stand by secretaire");]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</sequenceFlow>
<userTask id="standbySecretaire" name="Stand-by secrétaire" activiti:assignee="${reviewAssignee.properties.userName}" activiti:formKey="wfvd:activitiReviewTaskStandBy">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
task.setVariable("bpm_workflowDescription",execution.getVariable("bpm_workflowDescription"));
task.setVariable("bpm_priority",execution.getVariable("bpm_priority"));
logger.log("CREATE - formulaire Standby");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[<import resource="classpath:alfresco/extension/workflows/js/validation-documed.js">
logger.log("COMPLETE StandBy - Before mainValidationSecretaire()");
mainValidationSecretaire();
logger.log("COMPLETE StandBy - After mainValidationSecretaire()");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow17" sourceRef="reviewDecision" targetRef="standbySecretaire">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("flow 17 - TAKE - EA");]]></activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${execution.getVariable('wfvd_reviewOutcomeEnreg') == 'EA'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow18" sourceRef="standbySecretaire" targetRef="exclusivegateway3"></sequenceFlow>
</process>
03-16-2018 01:45 PM
Can you provide the bmpn file as an attachment instead of copying the text here?
I tried to import it using a bmpn editor, but it says the file is not ok.
03-17-2018 07:12 AM
ok, it's done
03-16-2018 12:04 PM
No one can help me ?
03-17-2018 08:58 AM
The validation secretaire task is a multi-instance task. In order for task properties to be used in an exclusive gateway they need to be copied into the execution - and each parallel instance of the task has its own execution as a child of the global execution (remember: Activiti variable scopes are hierarchial with multiple layers depending on the runtime fork/join behaviour of the process). Are you sure you are copying the values correctly and that there aren't any accidental overrides, i.e. in case you have two instances in that task with different values?
03-18-2018 11:43 AM
Yes i think the task properties are copied because the log shows the values just before exclusive gateway (Sequence Flow 2):
03-18-2018 06:28 PM
I just realised you are using execution.getVariable() in your flow conditions. Actually, this isn't needed because all the execution variables are globally accessible. So the conditions can be simplified to e.g. ${wfvd_reviewOutcomeEng == 'EA'}
03-19-2018 03:59 AM
Explore our Alfresco products with the links below. Use labels to filter content by product module.