Setting CandidateGroup from form filled in previous task

Writing this up even though I know that there is a lot of info, I wasn’t able to pull it off and spent close to 2 full days on this. Note that I am trying to use just the modeler application, haven’t taken this to eclipse yet, because I am sure there is a way to do it without doing that

The job really is to feed in a candidateGroup to process in a user task (through a form in that task), and then in the next user task onwards, assign the task to that candidate group.

Here is what I have tried so far:

  1. Set ${candidateGroupId} on “Assignments”->Candidate Groups, where candidateGroupId is the id of the form field in the previous user task. This moves onto the next step but is assigned to no-one.

  2. I tried using task listeners for this. So in the task Listener, I used that expression on create ${task.addCandidateGroup(var:get(candidateGroupId))}, and a bunch of different permutations as well, and that behaves the same as above. Funnily enough, if i replace the var:get… portion with the hardcoded string of the id of one of the candidate groups, that seems to work?

  3. I have tried setting execution and task variables as well, and none of those seem to work as it cant find the property.

Any tips on what I must be missing out here? It seems to be a realllly straight forward thing which is why I am not sure what I am doing wrong here.

In addition to this, I have noticed that the candidateGroupId is null, after setting a ScriptTaskListener on complete event of the first step. That means it never gets saved?

Can you share the bpmn xml you’ve got so far, that would help a lot.

That should be ok. What happens if you don’t use a function, but execution.getVariable or candidateGroupId direclty? Like ${task.addCandidateGroup(candidateGroupId)}

I’m not sure why a ScriptTaskListener would be needed here. Isn’t a regular expression on the task listener ok?

Anyway, this should indeed just work, if we have the bpmn xml it’s going to be easier to give relevant pointers :slight_smile:

<?xml version="1.0" encoding="UTF-8"?> ExclusiveGateway_0tves3v EndEvent_0ripgde ServiceTask_0zg9r2s mailtask1 mailtask2 sid-6DD3A6ED-4DF4-4CE0-87D3-72D9734EC3B9 SequenceFlow_10dcogo SequenceFlow_0ikchw3 SequenceFlow_0uabgth StartEventProcessStarted UserTask_0ot7gwv UserTask_1ncbr05 UserTask_0ognoho EndEventProcessEnded boundary SequenceFlow_1gmikym SequenceFlow1 SequenceFlow_1an0g5b sid-2F54CAC5-AACA-4297-9929-9D6481609E7C SequenceFlow_113vdzc sid-63A5665E-7F0C-470A-A998-5A0D5B2292A5 PT10S













<bpmndi:BPMNDiagram id=“BPMNDiagram_Collaboration”>
<bpmndi:BPMNPlane bpmnElement=“Collaboration” id=“BPMNPlane_Collaboration”>
<bpmndi:BPMNShape bpmnElement=“Participant_0n6x8wz” id=“BPMNShape_Participant_0n6x8wz”>
<omgdc:Bounds height=“605.0” width=“1218.0” x=“156.0” y=“65.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“Lane_1525i68” id=“BPMNShape_Lane_1525i68”>
<omgdc:Bounds height=“415.0” width=“1188.0” x=“186.0” y=“255.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“ExclusiveGateway_0tves3v” id=“BPMNShape_ExclusiveGateway_0tves3v”>
<omgdc:Bounds height=“40.0” width=“40.0” x=“761.0” y=“455.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“EndEvent_0ripgde” id=“BPMNShape_EndEvent_0ripgde”>
<omgdc:Bounds height=“28.0” width=“28.0” x=“1020.0” y=“405.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“ServiceTask_0zg9r2s” id=“BPMNShape_ServiceTask_0zg9r2s”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“570.0” y=“435.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“mailtask1” id=“BPMNShape_mailtask1”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“570.0” y=“285.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“mailtask2” id=“BPMNShape_mailtask2”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“300.0” y=“285.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“Lane_0r6sr76” id=“BPMNShape_Lane_0r6sr76”>
<omgdc:Bounds height=“190.0” width=“1188.0” x=“186.0” y=“65.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“StartEventProcessStarted” id=“BPMNShape_StartEventProcessStarted”>
<omgdc:Bounds height=“30.0” width=“30.0” x=“240.0” y=“120.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“UserTask_0ot7gwv” id=“BPMNShape_UserTask_0ot7gwv”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“570.0” y=“105.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“UserTask_1ncbr05” id=“BPMNShape_UserTask_1ncbr05”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“300.0” y=“90.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“UserTask_0ognoho” id=“BPMNShape_UserTask_0ognoho”>
<omgdc:Bounds height=“80.0” width=“100.0” x=“885.0” y=“105.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“EndEventProcessEnded” id=“BPMNShape_EndEventProcessEnded”>
<omgdc:Bounds height=“28.0” width=“28.0” x=“1230.0” y=“75.0”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement=“boundary” id=“BPMNShape_boundary”>
<omgdc:Bounds height=“31.0” width=“31.0” x=“564.5601444806182” y=“170.01869400517”></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_0ikchw3” id=“BPMNEdge_SequenceFlow_0ikchw3”>
<omgdi:waypoint x=“781.2977611940298” y=“455.29850746268653”></omgdi:waypoint>
<omgdi:waypoint x=“786.0” y=“145.0”></omgdi:waypoint>
<omgdi:waypoint x=“884.9999999999834” y=“145.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_1gmikym” id=“BPMNEdge_SequenceFlow_1gmikym”>
<omgdi:waypoint x=“620.0” y=“184.95”></omgdi:waypoint>
<omgdi:waypoint x=“620.0” y=“285.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_0uabgth” id=“BPMNEdge_SequenceFlow_0uabgth”>
<omgdi:waypoint x=“800.5626585928461” y=“475.38365384615383”></omgdi:waypoint>
<omgdi:waypoint x=“1036.0” y=“480.0”></omgdi:waypoint>
<omgdi:waypoint x=“1036.0” y=“458.9499750252922”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“sid-2F54CAC5-AACA-4297-9929-9D6481609E7C” id=“BPMNEdge_sid-2F54CAC5-AACA-4297-9929-9D6481609E7C”>
<omgdi:waypoint x=“564.5601407974265” y=“186.01869400517”></omgdi:waypoint>
<omgdi:waypoint x=“350.0” y=“186.01869400517”></omgdi:waypoint>
<omgdi:waypoint x=“350.0” y=“285.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow1” id=“BPMNEdge_SequenceFlow1”>
<omgdi:waypoint x=“269.92970434779033” y=“134.2115980805558”></omgdi:waypoint>
<omgdi:waypoint x=“299.99999999999966” y=“132.62894736842105”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_1an0g5b” id=“BPMNEdge_SequenceFlow_1an0g5b”>
<omgdi:waypoint x=“984.9499999999658” y=“145.0”></omgdi:waypoint>
<omgdi:waypoint x=“1244.0” y=“145.0”></omgdi:waypoint>
<omgdi:waypoint x=“1244.0” y=“102.94995046207684”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_113vdzc” id=“BPMNEdge_SequenceFlow_113vdzc”>
<omgdi:waypoint x=“399.95000000000005” y=“149.97737556561086”></omgdi:waypoint>
<omgdi:waypoint x=“569.9999999999999” y=“146.13009049773754”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“sid-63A5665E-7F0C-470A-A998-5A0D5B2292A5” id=“BPMNEdge_sid-63A5665E-7F0C-470A-A998-5A0D5B2292A5”>
<omgdi:waypoint x=“399.95” y=“120.0726392251816”></omgdi:waypoint>
<omgdi:waypoint x=“556.5” y=“89.0”></omgdi:waypoint>
<omgdi:waypoint x=“1230.0” y=“89.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“SequenceFlow_10dcogo” id=“BPMNEdge_SequenceFlow_10dcogo”>
<omgdi:waypoint x=“669.9499999999999” y=“475.0”></omgdi:waypoint>
<omgdi:waypoint x=“761.0” y=“475.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement=“sid-6DD3A6ED-4DF4-4CE0-87D3-72D9734EC3B9” id=“BPMNEdge_sid-6DD3A6ED-4DF4-4CE0-87D3-72D9734EC3B9”>
<omgdi:waypoint x=“620.0” y=“364.95000000000005”></omgdi:waypoint>
<omgdi:waypoint x=“620.0” y=“435.0”></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

That what the bpmn xml looks like

And yes you are right, a ScriptTaskListener is not required, but the simple expression on the task listener didnt work so I was trying every other alternative.

I tried using execution.getVariable or cadidadateGroupId directly, it gave the same result as I mentioned, that it doesn’t add the candidate group. It only really works if the value that I am expecting is hardcoded in.

In the above bpmn xml, the variable is called assigneegroup because that is the id of the form field that is supplied the value. Perhaps there is something I can do the in form itself to help the cause?

The xml seems to have not been added properly, can you add the missing part (which has the important bits for this discussion)?

<?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:flowable="http://flowable.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.flowable.org/processdef">
 <process id="testflow" name="TestFlow" isExecutable="true">
<startEvent id="start1" flowable:formFieldValidation="true"></startEvent>
<userTask id="usertask1" name="usertask1" flowable:assignee="$INITIATOR" flowable:formKey="basic2" flowable:formFieldValidation="true">
  <extensionElements>
    <modeler:activiti-idm-initiator xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:activiti-idm-initiator>
  </extensionElements>
</userTask>
<sequenceFlow id="sid-4AECE65F-916C-448E-95D5-3E1EBEAED9DB" sourceRef="start1" targetRef="usertask1"></sequenceFlow>
<userTask id="usertask2" name="usertask2" flowable:candidateGroups="${candidategroups}" flowable:formFieldValidation="true"></userTask>
<sequenceFlow id="sid-95520920-3CA0-48A5-B7AB-8E65C663C66B" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<endEvent id="end1"></endEvent>
<sequenceFlow id="sid-8CDECB52-9B85-4832-AD36-98CFC2ED8546" sourceRef="usertask2" 
targetRef="end1"></sequenceFlow>
</process>
 <bpmndi:BPMNDiagram id="BPMNDiagram_testflow">
    <bpmndi:BPMNPlane bpmnElement="testflow" id="BPMNPlane_testflow">
     <bpmndi:BPMNShape bpmnElement="start1" id="BPMNShape_start1">
    <omgdc:Bounds height="30.0" width="30.0" x="165.0" y="225.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
    <omgdc:Bounds height="80.0" width="100.0" x="240.0" y="195.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
    <omgdc:Bounds height="80.0" width="100.0" x="385.0" y="200.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="end1" id="BPMNShape_end1">
    <omgdc:Bounds height="28.0" width="28.0" x="530.0" y="226.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNEdge bpmnElement="sid-8CDECB52-9B85-4832-AD36-98CFC2ED8546" id="BPMNEdge_sid-8CDECB52-9B85-4832-AD36-98CFC2ED8546">
    <omgdi:waypoint x="484.95000000000005" y="240.0"></omgdi:waypoint>
    <omgdi:waypoint x="530.0" y="240.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-95520920-3CA0-48A5-B7AB-8E65C663C66B" id="BPMNEdge_sid-95520920-3CA0-48A5-B7AB-8E65C663C66B">
    <omgdi:waypoint x="339.95000000000005" y="235.0"></omgdi:waypoint>
    <omgdi:waypoint x="362.5" y="235.0"></omgdi:waypoint>
    <omgdi:waypoint x="362.5" y="240.0"></omgdi:waypoint>
    <omgdi:waypoint x="384.999999999986" y="240.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-4AECE65F-916C-448E-95D5-3E1EBEAED9DB" id="BPMNEdge_sid-4AECE65F-916C-448E-95D5-3E1EBEAED9DB">
    <omgdi:waypoint x="194.94998702926875" y="240.0"></omgdi:waypoint>
    <omgdi:waypoint x="217.5" y="240.0"></omgdi:waypoint>
    <omgdi:waypoint x="217.5" y="235.0"></omgdi:waypoint>
    <omgdi:waypoint x="239.99999999998602" y="235.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

I hope that is better, sorry about keeping this off for so long, I didn’t realize that a lot of it was missing, it just that this doesn’t actually show the forms that I am using. the id of the field that i fill out is candidategroups in this case (this is a new project so the variable names might differ but its still the same principle.)

The field that i use in the form is a “group of people” field, whose values i get from the groups i created in the IDM app, I hope that is the right way to use it. I appreciate the help @joram

Right, I dove a littler deeper into this and attached the flowable debugger, which i discovered recently. Apparently the variable exists but it’s type is set to “null” and the value is empty.

This leads me to believe that the value doesn’t actually get set when selecting from a list, even though the list shows up. What I am going to try next is remove the dropdown and see if i can populate an “options” menu, though I feel like this is a silly bug to be encountering and I might be doing something wrong here.

Can you check and see what data gets passed in the network tab? Does it contain the value of the dropdown?