im developing a web application to manage alfresco workflows using Rest api , in my process i have an exclusive gateway with a condition on flow22 as shown in this image :
(if decision variable is equal to 'approve' the process moves to task 3 )
For the first and second task everything works fine except i get this error while completing task2 with Rest, knowing that i already set my variable to approve .
this is my bpm
<?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" 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://www.activiti.org/test">
<process id="pres" name="prestation" isExecutable="true">
<startEvent id="startevent1" name="Start" activiti:initiator="${initiator.properties.userName}" activiti:formKey="pfewf:submitHelloWorldTask"></startEvent>
<userTask id="usertask1" name="Remplir formulaire demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:demandepres">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemA',task.getVariableLocal('pfewf_nomprenomDem'));
execution.setVariable('pfewf_ipDemA',task.getVariableLocal('pfewf_ipDem'));
execution.setVariable('pfewf_organismeDemA',task.getVariableLocal('pfewf_organismeDem'));
execution.setVariable('pfewf_refDemA',task.getVariableLocal('pfewf_refDem'));
execution.setVariable('pfewf_appDemA',task.getVariableLocal('pfewf_appDem'));
execution.setVariable('pfewf_dateDemA',task.getVariable('pfewf_dateDem'));
execution.setVariable('pfewf_typeDemA',task.getVariableLocal('pfewf_typeDem'));
execution.setVariable('pfewf_userDetailsA',task.getVariableLocal('pfewf_userDetails'));
execution.setVariable('pfewf_respTech',task.getVariableLocal('pfewf_respTech'));
execution.setVariable('pfewf_respTechR',task.getVariableLocal('pfewf_respTech'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[var date = new Date();
var timeInMillisecs = date.getTime();
var ISODate = utils.toISO8601(timeInMillisecs);
var origDate = utils.fromISO8601(ISODate);
execution.setVariable('pfewf_dateDem',origDate);]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('pfewf_userDetails',task.getVariable('pfewf_userDetails'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="Responsable technique" activiti:assignee="${pfewf_respTech.properties.userName}" activiti:formKey="pfewf:avisTech">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemR',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemR',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemR',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemR',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemR',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemR',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemR',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsR',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_userDetailsA',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testR',task.getVariable('pfewf_testA'));
execution.setVariable('pfewf_avisRespTech',task.getVariableLocal('pfewf_avisRespTech'));
execution.setVariable('pfewf_respTechR',task.getVariable('pfewf_respTech'));
execution.setVariable('pfewf_remarquesR',task.getVariableLocal('pfewf_remarquesA'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<userTask id="usertask3" name="Revision demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:revisionDem"></userTask>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow8" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow9" name="a reviser" sourceRef="exclusivegateway1" targetRef="usertask3">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
== 'A Rectifier'}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow10" sourceRef="usertask3" targetRef="exclusivegateway2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow11" name="annuler" sourceRef="exclusivegateway2" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
== 'Annuler'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow12" name="renvoyer" sourceRef="exclusivegateway2" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
== 'Renvoyer'}]]></conditionExpression>
</sequenceFlow>
<endEvent id="endevent2" name="End"></endEvent>
<sequenceFlow id="flow13" name="refuser" sourceRef="exclusivegateway1" targetRef="endevent2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
== 'Refuser'}]]></conditionExpression>
</sequenceFlow>
<userTask id="usertask4" name="Avis DHE" activiti:candidateGroups="GROUP_DHE" activiti:formKey="pfewf:dhe">
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemD',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemD',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemD',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemD',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemD',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemD',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemD',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsD',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testD',task.getVariable('pfewf_testA'));
execution.setVariable('pfewf_nomprenomDemDr',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemDr',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemDr',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemDr',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemDr',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemDr',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemDr',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsDr',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testDr',task.getVariable('pfewf_testA'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow14" name="valider" sourceRef="exclusivegateway1" targetRef="usertask4">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
== 'Valider'}]]></conditionExpression>
</sequenceFlow>
<userTask id="usertask5" name="Avis DRSM" activiti:candidateGroups="GROUP_DRSM" activiti:formKey="pfewf:drsm"></userTask>
<sequenceFlow id="flow15" sourceRef="usertask4" targetRef="usertask5"></sequenceFlow>
<endEvent id="endevent3" name="End"></endEvent>
<sequenceFlow id="flow16" sourceRef="usertask5" targetRef="endevent3"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_pres">
<bpmndi:BPMNPlane bpmnElement="pres" id="BPMNPlane_pres">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="310.0" y="323.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="71.0" width="112.0" x="400.0" y="305.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="65.0" width="105.0" x="558.0" y="308.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
<omgdc:Bounds height="55.0" width="105.0" x="688.0" y="461.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="720.0" y="321.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
<omgdc:Bounds height="40.0" width="40.0" x="590.0" y="468.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="480.0" y="471.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35.0" width="35.0" x="723.0" y="220.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
<omgdc:Bounds height="55.0" width="105.0" x="805.0" y="314.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
<omgdc:Bounds height="55.0" width="105.0" x="955.0" y="314.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
<omgdc:Bounds height="35.0" width="35.0" x="1105.0" y="324.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="345.0" y="340.0"></omgdi:waypoint>
<omgdi:waypoint x="400.0" y="340.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="512.0" y="340.0"></omgdi:waypoint>
<omgdi:waypoint x="558.0" y="340.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="663.0" y="340.0"></omgdi:waypoint>
<omgdi:waypoint x="720.0" y="341.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="740.0" y="361.0"></omgdi:waypoint>
<omgdi:waypoint x="740.0" y="461.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="16.0" width="48.0" x="752.0" y="390.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
<omgdi:waypoint x="688.0" y="488.0"></omgdi:waypoint>
<omgdi:waypoint x="630.0" y="488.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
<omgdi:waypoint x="590.0" y="488.0"></omgdi:waypoint>
<omgdi:waypoint x="515.0" y="488.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="16.0" width="42.0" x="532.0" y="500.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
<omgdi:waypoint x="610.0" y="468.0"></omgdi:waypoint>
<omgdi:waypoint x="610.0" y="373.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="16.0" width="48.0" x="615.0" y="431.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
<omgdi:waypoint x="740.0" y="321.0"></omgdi:waypoint>
<omgdi:waypoint x="740.0" y="255.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="16.0" width="39.0" x="752.0" y="296.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
<omgdi:waypoint x="760.0" y="341.0"></omgdi:waypoint>
<omgdi:waypoint x="805.0" y="341.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="16.0" width="100.0" x="760.0" y="341.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
<omgdi:waypoint x="910.0" y="341.0"></omgdi:waypoint>
<omgdi:waypoint x="955.0" y="341.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
<omgdi:waypoint x="1060.0" y="341.0"></omgdi:waypoint>
<omgdi:waypoint x="1105.0" y="341.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
How can i deal with exclusivegateways through Rest api ?
Thank you in advance.
I strongly doubt that the decision variable is already set, after completing task2 you can check the value of the variable by calling this endpoint:
GET /tasks/{taskId}/variables
To set variables before completing a task you have to do it like this
URL:
PUT /tasks/{taskId}?select=state,variables
Request body:
{
"state": "completed",
"variables": [
{
"name": "decision",
"type": "d_text",
"value": "approve",
"scope": "global"
}
]
}
There are many solutions:
You can use this condition in your flow14 "${pfewf_avisRespTech != 'Refuser' && pfewf_avisRespTech != 'A Rectifier'}".
In your model set the default value of pfewf_avisRespTech as "Valider" for example
Before asking workflow engine to complete your task, ask him to update the value of your pfewf_avisRespTech
In the complete listener of task2 check the value of "pfewf_avisRespTech" if it's equal to "" or null gives it some value.
Related
I have a bpmn process/file where i intend to pass data in json format to a rest api via a post request. I have included the xml for the workflow below,
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions
xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0wl4do2" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.6.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
<bpmn:process id="Process_06dpeub" isExecutable="true">
<bpmn:sequenceFlow id="Flow_16ic7a9" sourceRef="StartEvent_1" targetRef="Activity_0nfsr66" />
<bpmn:endEvent id="Event_0q8baf4">
<bpmn:incoming>Flow_1gchegt</bpmn:incoming>
</bpmn:endEvent>
<bpmn:startEvent id="StartEvent_1" name="Employee record">
<bpmn:extensionElements />
<bpmn:outgoing>Flow_16ic7a9</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_0lrekv7" messageRef="Message_1bc80bb" />
</bpmn:startEvent>
<bpmn:serviceTask id="Activity_16u939z" name="Add employee">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:input source="=body" target="payload" />
<zeebe:output source="= result" target="employeeResult" />
</zeebe:ioMapping>
<zeebe:taskDefinition type="legacy" />
<zeebe:taskHeaders>
<zeebe:header key="url" value="/add/employee" />
<zeebe:header key="method" value="post" />
</zeebe:taskHeaders>
</bpmn:extensionElements>
<bpmn:incoming>Flow_09bylzt</bpmn:incoming>
<bpmn:outgoing>Flow_1gchegt</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1gchegt" sourceRef="Activity_16u939z" targetRef="Event_0q8baf4" />
<bpmn:serviceTask id="Activity_0nfsr66" name="Generate Payload">
<bpmn:extensionElements>
<zeebe:taskDefinition type="script" retries="2" />
<zeebe:taskHeaders>
<zeebe:header key="script" value="{ "employmentType": "LIMITED", "onboardingCheck": "false", "middleName": "ALI", "permittedDependents": "0", "personalEmail": "ayub_a#outlook.com", "businessRoleId": "1", "lastName": "Gama", "gradeId": "", "leaveGroupId": "1", "businessPhone": "0523308810", "leaveAllowance": "0", "personalAddress": "DUBAI", "employeeCode": "234234", "dateOfBirth": "1978-08-08", "firstName": "Alpha4", "citizenship_countryId": "1", "nationality": "Afghan", "salutation": "Mr", "personalPhone": "0523308810", "maritalStatus": "SINGLE", "leaveApprover": "1", "residencyVisaLocation": "DUBAI", "workingPatternId": "1", "businessEmail": "Alpha7#gmail.com", "preferredName": "Alpha4", "projectedEmploymentDate": "1978-08-08", "startDate": "2021-05-30", "currentYearLeaveAllocation": "0", "gender": "M" }" />
<zeebe:header key="language" value="mustache" />
</zeebe:taskHeaders>
<zeebe:ioMapping>
<zeebe:output source="=result" target="body" />
</zeebe:ioMapping>
</bpmn:extensionElements>
<bpmn:incoming>Flow_16ic7a9</bpmn:incoming>
<bpmn:outgoing>Flow_09bylzt</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_09bylzt" sourceRef="Activity_0nfsr66" targetRef="Activity_16u939z" />
</bpmn:process>
<bpmn:message id="Message_1bc80bb" name="payload" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_06dpeub">
<bpmndi:BPMNShape id="Event_0q8baf4_di" bpmnElement="Event_0q8baf4">
<dc:Bounds x="572" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1ovhyfk_di" bpmnElement="StartEvent_1">
<dc:Bounds x="162" y="99" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="138" y="142" width="84" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_0veej1v" bpmnElement="Activity_16u939z">
<dc:Bounds x="420" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_14olppq" bpmnElement="Activity_0nfsr66">
<dc:Bounds x="260" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_16ic7a9_di" bpmnElement="Flow_16ic7a9">
<di:waypoint x="198" y="117" />
<di:waypoint x="260" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1gchegt_di" bpmnElement="Flow_1gchegt">
<di:waypoint x="520" y="117" />
<di:waypoint x="572" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09bylzt_di" bpmnElement="Flow_09bylzt">
<di:waypoint x="360" y="117" />
<di:waypoint x="420" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Authentication is done server side and the logs do show that the request is received but nothing else, which is unhelpful. The url "/add/employee" gets preappended on the server side and becomes a valid url, so no issue there.
I am not certain that i modelled this correctly as the request gets successfully processed from postman whereas it fails when done via the workflow. The error observed on Operate is,
{
"name": "GeneralError",
"message": "Cannot read property 'id' of undefined",
"code": 500,
"className": "general-error",
"data": {},
"errors": {},
"status_code": 500,
"reason_code": "Internal Server Error"
}
Not much to go on, though i did initially get the same error on postman, it turns out some mandatory fields were missed in the payload. The payload would be what you would find in header script of the Generate Payload task.
What i am trying to get help on here is to see whether there is anything wrong with the bpmn model.
I want to create a custom workflow in order to review a document by a group that contains two users, those two users should be able to review the document in parallel. How can i do that?
All I have done is review a document by one user ( see attached code), what do i need to change in order to assign the review task to a group?
activiti-demand-workflow-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>
<bean id="lifecycle.workflowaBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">
<list>
<props>
<prop key="engineId">activiti</prop>
<prop key="location">alfresco/extension/activiti-demand.bpmn20.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
</list>
</property>
<property name="models">
<list>
<value>alfresco/extension/workflowdemandModel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco/extension/activiti-demand-messages</value>
</list>
</property>
</bean>
</beans>
activiti-demand-messages.properties
activitiDemand.workflow.title=Demand
activitiDemand.workflow.description=Process of demand validation
wfa_workflowmodelk.type.wfa_submitReviewTaskk.title=review demand
wfa_workflowmodelk.type.wfa_submitReviewTaskk.description=review demand
workflowdemandModel.xml
<?xml version="1.0" encoding="UTF-8"?>
<model name="wfa:workflowmodelk" 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="wfa.workflow.model" prefix="wfa"/>
</namespaces>
<types>
<!-- -->
<!-- Basic Review & Approve Tasks -->
<!-- -->
<type name="wfa:submitReviewTaskk">
<parent>bpm:startTask</parent>
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
</type>
<type name="wfa:activitiReviewTaskk">
<parent>bpm:activitiOutcomeTask</parent>
<properties>
<property name="wfa:reviewOutcome">
<type>d:text</type>
<default>Reject</default>
<constraints>
<constraint name="wfa: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/workflow/1.0}reviewOutcome</default>
</property>
</overrides>
</type>
<type name="wfa:approvedTaskk">
<parent>bpm:workflowTask</parent>
</type>
<type name="wfa:rejectedTaskk">
<parent>bpm:workflowTask</parent>
</type>
</types>
</model>
activiti-demand.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://alfresco.org">
<process id="activitiDemand" name="review process">
<startEvent id="start" name="Submit Review Task"
activiti:formKey="wfa:submitReviewTaskk" />
<sequenceFlow id='flow1'
sourceRef='start'
targetRef='reviewTask' />
<userTask id="reviewTask" name="Review Task"
activiti:formKey="wfa:activitiReviewTaskk">
<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.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('wfa_reviewOutcome', task.getVariable('wfa_reviewOutcome'));
if (task.getVariable('wfa_reviewOutcome') == 'Approve')
{
bpm_package.children[0].addTag("Approved_demand");
}
else
{
if (task.getVariable('wfa_reviewOutcome') == 'Reject')
{
bpm_package.children[0].addTag("Rejected_demand");
}
}
</activiti:string>
</activiti:field>
<activiti:field name="runAs">
<activiti:string>admin</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${bpm_assignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<!-- <sequenceFlow id='flow2'
sourceRef='reviewTask'
targetRef='reviewDecision' /> -->
<!-- <exclusiveGateway id="reviewDecision" name="Review Decision" /> -->
<!-- <sequenceFlow id='flow3' sourceRef='reviewDecision' targetRef='approved' >
<conditionExpression xsi:type="tFormalExpression">${wfa_reviewOutcome == 'Approve'}</conditionExpression>
</sequenceFlow>
<sequenceFlow id='flow4'
sourceRef='reviewDecision'
targetRef='rejected' />-->
<!-- <userTask id="approved" name="Document Approved"
activiti:formKey="wfa:approvedTaskk" >
<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>
execution.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>-->
<!-- <userTask id="rejected" name="Document Rejected"
activiti:formKey="wfa:rejectedTaskk" >
<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>
execution.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>-->
<!-- <sequenceFlow id='flow5' sourceRef='approved'
targetRef='end' />
<sequenceFlow id='flow6' sourceRef='rejected'
targetRef='end' />-->
<endEvent id="end" />
</process>
<!-- Graphical representaion of diagram -->
<bpmndi:BPMNDiagram id="BPMNDiagram_activitiReview">
<bpmndi:BPMNPlane bpmnElement="activitiReview"
id="BPMNPlane_activitiReview">
<bpmndi:BPMNShape bpmnElement="start"
id="BPMNShape_start">
<omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="reviewTask"
id="BPMNShape_reviewTask">
<omgdc:Bounds height="55" width="105" x="125"
y="190"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="reviewDecision"
id="BPMNShape_reviewDecision">
<omgdc:Bounds height="40" width="40" x="290" y="197"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="approved"
id="BPMNShape_approved">
<omgdc:Bounds height="55" width="105" x="390"
y="97"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="rejected"
id="BPMNShape_rejected">
<omgdc:Bounds height="55" width="105" x="390"
y="297"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="35" width="35" x="555" y="307"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="65" y="217"></omgdi:waypoint>
<omgdi:waypoint x="125" y="217"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="230" y="217"></omgdi:waypoint>
<omgdi:waypoint x="290" y="217"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="310" y="197"></omgdi:waypoint>
<omgdi:waypoint x="310" y="124"></omgdi:waypoint>
<omgdi:waypoint x="390" y="124"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="310" y="237"></omgdi:waypoint>
<omgdi:waypoint x="310" y="324"></omgdi:waypoint>
<omgdi:waypoint x="390" y="324"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="495" y="124"></omgdi:waypoint>
<omgdi:waypoint x="572" y="124"></omgdi:waypoint>
<omgdi:waypoint x="572" y="307"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="495" y="324"></omgdi:waypoint>
<omgdi:waypoint x="555" y="324"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
You cannot assign a task to a group. But you can have multiple instance of a task.
Define your review task as a multi-instance task.
<userTask id="reviewTask" name="Review Task" activiti:formKey="wfa:activitiReviewTaskk">
<multiInstanceLoopCharacteristics isSequential="false">
<loopDataInputRef>assigneeList</loopDataInputRef>
<inputDataItem name="assignee" />
</multiInstanceLoopCharacteristics>
...
</userTask>
To create an instance for each user of the reviewers group you can set assigneeList to the list of users from the group when the workflow starts.
You should also define when is the task to be considered completed. Two or more instances of the review task are completed?
<completionCondition>${nrOfCompletedInstances >= 2 }</completionCondition>
Or all of them?
<completionCondition>${nrOfCompletedInstances==nrOfInstances}</completionCondition>
Finally, you should also think about what the overall review result ought to be. Do all users have to approve the document in order for it to be considered approved? Two or more? At least 50%?
One way to accomplish something like this is to increase the value of a counter whenever an instance of the review task ends with approval, and to check this value when the task is resolved.
See also Multi-instance tasks and Xml representation of multi-instance tasks.
You can assign a task to a group/s with this attribute inside your userTask tag:
activiti:candidateGroups="GROUP_development"
You can add more than one group in a comma separated value format and each group name must be prefixed with "GROUP_".
Have in mind that doing in that way converts your task in pooled task wich means that the first user who complete the task finalize it.
I am working on sap fiori project which displays data in chart format. In a dual series chart, I want to remove the gap in between columns, which you can see below:
I tried searching for attributes for vizframe.
<layout:flexContent>
<viz:Popover id="idPopOver"></viz:Popover>
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='100%' width="100%" vizType='column'>
<viz:dataset>
<viz.data:FlattenedDataset data="{/milk}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Week"
value="{Week}" />
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition name="Revenue"
value="{Revenue}" />
<viz.data:MeasureDefinition name="Cost"
value="{Cost}" />
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<viz:feeds>
<viz.feeds:FeedItem id='valueAxisFeed' uid="valueAxis" type="Measure"
values="Revenue" />
<viz.feeds:FeedItem id='categoryAxisFeed' uid="categoryAxis" type="Dimension"
values="Week" />
</viz:feeds>
</viz:VizFrame>
</layout:flexContent>
You can use the vizProperties and set plotArea => gap => innerGroupSpacing
<viz:VizFrame id="idVizFrame" uiConfig="{applicationSet:'fiori'}"
height='100%' width="100%" vizType='column'
vizProperties="{ plotArea : {gap: {innerGroupSpacing:0}} }">
I am using this sample
<viz:VizFrame id="oVizFrame" busy="false" busyIndicatorDelay="1000" visible="true" uiConfig="{ 'applicationSet': 'fiori' }" vizType="pie" legendVisible="true">
<viz:dataset>
<viz.data:FlattenedDataset data="{/book}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Item Category" value="{Item Category}"/>
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition group="1" name="Profit" value="{Profit}"/>
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<!-- sap.viz.ui5.data.Dataset -->
<viz:feeds>
<viz.feeds:FeedItem uid="size" type="Measure" values="Profit"/>
<viz.feeds:FeedItem uid="color" type="Dimension" values="Item Category"/>
</viz:feeds>
</viz:VizFrame>
I am not able to add more book properties like City and Profit to the existing pie chart. Please guide me.
You can certainly add more dimensions to the pie chart but only one measure will be allowed.
<viz:VizFrame id="oVizFrame" busy="false" busyIndicatorDelay="1000" visible="true" uiConfig="{ 'applicationSet': 'fiori' }" vizType="pie" legendVisible="true">
<viz:dataset>
<viz.data:FlattenedDataset data="{/book}">
<viz.data:dimensions>
<viz.data:DimensionDefinition name="Item Category" value="{Item Category}"/>
<viz.data:DimensionDefinition name="City" value="{City}"/>
</viz.data:dimensions>
<viz.data:measures>
<viz.data:MeasureDefinition group="1" name="Profit" value="{Profit}"/>
</viz.data:measures>
</viz.data:FlattenedDataset>
</viz:dataset>
<!-- sap.viz.ui5.data.Dataset -->
<viz:feeds>
<viz.feeds:FeedItem uid="size" type="Measure" values="Profit"/>
<viz.feeds:FeedItem uid="color" type="Dimension" values="Item Category"/>
<viz.feeds:FeedItem uid="color" type="Dimension" values="City"/>
</viz:feeds>
</viz:VizFrame>
sI use activiti for my workflow on alfresco 4.2.c. I want to assign to a group from my form selection. But when I press submit task it throws an exception: org.activiti.engine.ActivitiException: Unknown property used in expression
My activiti is:
<userTask id="kiemtranoidungthethuc" name="Kiểm tra nội dung, thể thức VB- Chuyển cho phòng TCHC" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wfdi:kiemtranoidungthethucTask_tc">
<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.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('wfdi_userVanthu', person);
execution.setVariable('wfdi_chapthuan_tc', task.getVariable('wfdi_chapthuan_tc'));
<!-- execution.setVariable('bpm_assignee', person);-->
execution.setVariable('bpm_dueDate', task.getVariable('dueDate'));
execution.setVariable('bpm_priority', task.priority);
execution.setVariable('bpm_groupAssignee',task.bpm_groupAssignee);
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<userTask id="kiemtrathethucchuky" name="Phòng TCHC - Kiểm tra thể thức, chữ ký - Chuyển cho BGH"
activiti:candidateGroups="${bpm_groupAssignee.properties.authorityName}" activiti:formKey="wfdi:kiemtrathethucchukyTask_tc">
<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.dueDate = bpm_workflowDueDate;
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_priority;
<!-- if (typeof bpm_comment != 'undefined') task.setVariable('bpm_comment', bpm_comment);-->
</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('wfdi_kiemtra_tc', task.getVariable('wfdi_kiemtra_tc'));
execution.setVariable('bpm_dueDate', task.getVariable('dueDate'));
execution.setVariable('bpm_priority', task.priority);
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
My form is:
<config evaluator="task-type" condition="wfdi:kiemtranoidungthethucTask_tc">
<forms>
<form>
<field-visibility>
<show id="message" />
<show id="taskOwner" />
<show id="bpm:priority" />
<show id="bpm:dueDate" />
<show id="bpm:taskId" />
<show id="packageItems" />
<show id="bpm:groupAssignee" />
<show id="bpm:comment" />
<show id="wfdi:chapthuan_tc" />
</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="items" appearance="title" label-id="workflow.set.items" />
<set id="assignee" appearance="title" label-id="workflow.set.assignee" />
<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:dueDate" set="info" label-id="workflow.field.due">
<control template="/org/alfresco/components/form/controls/info.ftl" />
</field>
<field id="packageItems" set="items" />
<field id="bpm:groupAssignee" label-id="workflow.field.review_group" set="assignee" />
<field id="bpm:comment" label-id="workflow.field.comment" set="response">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="wfdi:chapthuan_tc" label-id="workflow.field.outcome" set="response">
<control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
</field>
</appearance>
</form>
</forms>
My model is:
<type name="wfdi:kiemtranoidungthethucTask_tc">
<parent>bpm:workflowTask</parent>
<properties>
<property name="wfdi:chapthuan_tc">
<type>d:text</type>
<default>Tu_Choi</default>
<constraints>
<constraint name="wfdi:chapthuanOption_tc" type="LIST">
<parameter name="allowedValues">
<list>
<value>Chuyen_Phong_TCHC</value>
<value>Tu_Choi</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/workflow/1.0}chapthuan</default>
</property>
</overrides>
<mandatory-aspects>
<aspect>bpm:groupAssignee</aspect>
</mandatory-aspects>
I know the problem is: activiti:candidateGroups="${bpm_groupAssignee.properties.authorityName}"
but I don't know how to fix it.
Can anybody help me?
Thank in advance.