12-30-2017 06:02 AM
I have two association defined in aspect in my custom workflow model:
<aspect name="hxwf:multiassignaspect">
<associations>
<association name="hxwf:firstassignee">
<title>first assignee</title>
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cmerson</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
<association name="hxwf:secondassignee">
<title>second assignee</title>
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cmerson</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
</associations>
</aspect>
In my bpm Process Definition
<?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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="multiassignee" name="Multi Assignee" isExecutable="true">
<startEvent id="startevent1" name="Start" activiti:formKey="hxwf:starttask"></startEvent>
<userTask id="usertask1" name="First Assignee" activiti:assignee="${hxwf_firstassignee.properties.userName}">
</userTask>
<userTask id="usertask2" name="Second Assignee" activiti:assignee="${hxwf_secondassignee.properties.userName}"></userTask>
<sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
<sequenceFlow id="flow4" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
</process>
But the workflow haven't started and giving me the error as ''
Unknown property used in expression: ${hxwf_firstassignee.properties.userName}
I need to assign the task to first assignee when initiator starts workflow , then it goes to second assignee. Please help me to achieve that. Thanks in advance
12-31-2017 11:59 AM
You can try using a task listener, attached to the complete event, and then in the javascript code, do something like:
execution.setVariable('firstassignee', task.getVariable('hxwf_firstassignee'));
execution.setVariable('secondassignee', task.getVariable('hxwf_secondassignee'));
Then, on the next task, you can have the variables firstassignee and secondassignee being used as expressions on the assignee property, like ${firstassignee.properties.userName} and ${secondassignee.properties.userName}
01-02-2018 12:49 AM
I did the same , but when i start the workflow, its not getting started throwing error
'00020011 Failed to start workflow activiti$multiassignee:89:22416.'
Here is my bpm process code:
<?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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="multiassignee" name="Multi Assignee" isExecutable="true">
<startEvent id="startevent1" name="Start" activiti:formKey="hxwf:starttask"></startEvent>
<userTask id="usertask1" name="First Assignee" >
<extensionElements>
<activiti:taskListener class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener" event="complete">
<activiti:field name="script">
<activiti:string>
execution.setVariable('firstassignee', task.getVariable('hxwf_firstassignee'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${firstassignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<userTask id="usertask2" name="Second Assignee" >
<extensionElements>
<activiti:taskListener class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener" event="complete">
<activiti:field name="script">
<activiti:string>
execution.setVariable('secondassignee', task.getVariable('hxwf_secondassignee'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${secondassignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
<sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
<sequenceFlow id="flow4" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_multiassignee">
<bpmndi:BPMNPlane bpmnElement="multiassignee" id="BPMNPlane_multiassignee">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="20.0" y="190.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="250.0" y="180.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="410.0" y="185.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="550.0" y="190.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="355.0" y="207.0"></omgdi:waypoint>
<omgdi:waypoint x="410.0" y="212.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="515.0" y="212.0"></omgdi:waypoint>
<omgdi:waypoint x="550.0" y="207.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="55.0" y="207.0"></omgdi:waypoint>
<omgdi:waypoint x="250.0" y="207.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
If i am giving the assignee value directly, its working.Am i doing this correctly?please help me to resolve this
01-02-2018 03:03 AM
I think you have to change your user tasks like,
<userTask id="usertask1" name="First Assignee" activiti:assignee="${bpm_assignee.properties.userName}>
<extensionElements>
<activiti:taskListener class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener" event="complete">
<activiti:field name="script">
<activiti:string>
execution.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
01-03-2018 12:16 AM
Thanks for your reply.
That also tried before, when i show default bpm_assignee property there, then it will work, but in my case two association with class cmerson is defined in the model, so i don't think setting bpm_assignee in usertask will work.
01-03-2018 06:43 AM
In the task assignee configuration, have you tried something like this?
<userTask id="usertask" name="First Assignee" activiti:assignee="${firstassignee.properties.userName}">
Explore our Alfresco products with the links below. Use labels to filter content by product module.