How to set dynamic assignee with process variable

I am unable to get task when login as sales persion kadir@gardlerlighting.com

map.put(“salesPerson”,"kadir@gardlerlighting.com" );

flowable:assignee="${salesPerson}"

This is my scenario, can anyone create sample code in spring boot

 <?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="crm-warranty" name="crm warranty" isExecutable="true">
    <startEvent id="startEvent1"></startEvent>
    <userTask id="sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1" name="Create Ticket"></userTask>
    <sequenceFlow id="sid-42668AA2-8B74-4A02-9FB8-380126213436" sourceRef="startEvent1" targetRef="sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1"></sequenceFlow>
    <userTask id="sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A" name="Sales Person"  flowable:assignee="${salesPerson}">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65"></exclusiveGateway>
    <sequenceFlow id="sid-A2CB4572-C7FF-46A7-A6B5-ABF1B60E9920" sourceRef="sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A" targetRef="sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65"></sequenceFlow>
    <userTask id="sid-14B7DD1C-5288-4136-9168-9A18C8E235F2" name="Coordinator" flowable:assignee="${coordinator}">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7"></exclusiveGateway>
    <sequenceFlow id="sid-02EDD7A3-3ED0-498B-BB9D-961FC4358168" sourceRef="sid-14B7DD1C-5288-4136-9168-9A18C8E235F2" targetRef="sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7"></sequenceFlow>
    <endEvent id="sid-3F1E9A9D-B1E4-47DC-9F88-FC53FFBE0FC8"></endEvent>
    <sequenceFlow id="sid-C1BA7B51-A0CD-4E2C-972A-4DE809D07057" name="Under Warranty" sourceRef="sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65" targetRef="sid-14B7DD1C-5288-4136-9168-9A18C8E235F2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isUnderWarranty}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="sid-1B07662F-F8D4-4884-A583-DE5E83C521B0" name="Approved" sourceRef="sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7" targetRef="sid-3F1E9A9D-B1E4-47DC-9F88-FC53FFBE0FC8">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='approved'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="sid-0B383203-21D8-4DDF-9457-889B5C2E3B02" name="Rejected" sourceRef="sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7" targetRef="sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action=='reject'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="sid-5C641E82-4A03-4EC7-9B03-61C4B2F1088C" name="Warrant Expired" sourceRef="sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65" targetRef="sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${!isUnderWarranty}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="sid-705494E6-15C5-47E5-9B49-5151256EB4B4" sourceRef="sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1" targetRef="sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_crm-warranty">
    <bpmndi:BPMNPlane bpmnElement="crm-warranty" id="BPMNPlane_crm-warranty">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1" id="BPMNShape_sid-D092143E-550B-4C7B-91DD-EA419AD3FCB1">
        <omgdc:Bounds height="80.0" width="100.0" x="175.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A" id="BPMNShape_sid-907BCF3C-FFB9-48AD-893F-FD5AA188FD5A">
        <omgdc:Bounds height="80.0" width="100.0" x="546.0" y="136.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65" id="BPMNShape_sid-1DE19F2D-FB6B-4870-B32A-B8A52DA53D65">
        <omgdc:Bounds height="40.0" width="40.0" x="735.0" y="156.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-14B7DD1C-5288-4136-9168-9A18C8E235F2" id="BPMNShape_sid-14B7DD1C-5288-4136-9168-9A18C8E235F2">
        <omgdc:Bounds height="80.0" width="100.0" x="915.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7" id="BPMNShape_sid-1B8235DA-2E13-4CBC-9DC4-D3033C0EB1D7">
        <omgdc:Bounds height="40.0" width="40.0" x="1050.0" y="158.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-3F1E9A9D-B1E4-47DC-9F88-FC53FFBE0FC8" id="BPMNShape_sid-3F1E9A9D-B1E4-47DC-9F88-FC53FFBE0FC8">
        <omgdc:Bounds height="28.0" width="28.0" x="1170.0" y="162.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-1B07662F-F8D4-4884-A583-DE5E83C521B0" id="BPMNEdge_sid-1B07662F-F8D4-4884-A583-DE5E83C521B0">
        <omgdi:waypoint x="1089.9334026622194" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="1130.0" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="1130.0" y="176.0"></omgdi:waypoint>
        <omgdi:waypoint x="1170.0" y="176.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-705494E6-15C5-47E5-9B49-5151256EB4B4" id="BPMNEdge_sid-705494E6-15C5-47E5-9B49-5151256EB4B4">
        <omgdi:waypoint x="274.95000000000005" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="546.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-5C641E82-4A03-4EC7-9B03-61C4B2F1088C" id="BPMNEdge_sid-5C641E82-4A03-4EC7-9B03-61C4B2F1088C">
        <omgdi:waypoint x="749.5372460496613" y="190.50090293453724"></omgdi:waypoint>
        <omgdi:waypoint x="634.0" y="498.0"></omgdi:waypoint>
        <omgdi:waypoint x="225.0" y="284.0"></omgdi:waypoint>
        <omgdi:waypoint x="225.0" y="217.95000000000002"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-A2CB4572-C7FF-46A7-A6B5-ABF1B60E9920" id="BPMNEdge_sid-A2CB4572-C7FF-46A7-A6B5-ABF1B60E9920">
        <omgdi:waypoint x="645.9499999999605" y="176.0"></omgdi:waypoint>
        <omgdi:waypoint x="735.0" y="176.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-42668AA2-8B74-4A02-9FB8-380126213436" id="BPMNEdge_sid-42668AA2-8B74-4A02-9FB8-380126213436">
        <omgdi:waypoint x="129.9499984899576" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="174.9999999999917" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-C1BA7B51-A0CD-4E2C-972A-4DE809D07057" id="BPMNEdge_sid-C1BA7B51-A0CD-4E2C-972A-4DE809D07057">
        <omgdi:waypoint x="774.1092351716961" y="176.83124999999998"></omgdi:waypoint>
        <omgdi:waypoint x="847.0" y="180.0"></omgdi:waypoint>
        <omgdi:waypoint x="834.0" y="180.0"></omgdi:waypoint>
        <omgdi:waypoint x="914.9999999999997" y="178.76259541984732"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-0B383203-21D8-4DDF-9457-889B5C2E3B02" id="BPMNEdge_sid-0B383203-21D8-4DDF-9457-889B5C2E3B02">
        <omgdi:waypoint x="1068.4615384615383" y="159.52759948652124"></omgdi:waypoint>
        <omgdi:waypoint x="1064.0" y="106.0"></omgdi:waypoint>
        <omgdi:waypoint x="596.0" y="103.0"></omgdi:waypoint>
        <omgdi:waypoint x="596.0" y="136.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-02EDD7A3-3ED0-498B-BB9D-961FC4358168" id="BPMNEdge_sid-02EDD7A3-3ED0-498B-BB9D-961FC4358168">
        <omgdi:waypoint x="1014.949999999971" y="178.0"></omgdi:waypoint>
        <omgdi:waypoint x="1050.0" y="178.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
1 Like

Here is a Spring Boot RestController that starts the crm-warranty process, queries for and starts the first task while assigning a salesPerson variable:


@RestController
@RequestMapping("/demo")
public class DemoRestController {

    private final RuntimeService runtimeService;
    private final TaskService taskService;

    public DemoRestController(RuntimeService runtimeService, TaskService taskService) {
        this.runtimeService = runtimeService;
        this.taskService = taskService;
    }

    @PostMapping("/{salesPerson}")
    public String startDemoProcess(@PathVariable("salesPerson") String salesPerson) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("crm-warranty");

        Map<String, Object> variables = new HashMap<>();
        variables.put("salesPerson", salesPerson);

        List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();

        tasks.forEach(task -> taskService.complete(task.getId(), variables));

        return processInstance.getId();
    }
}

I tested it by adding a kadir user to flowable-idmm, adding this controller to the flowable-rest WAR, and executing:

curl -X POST localhost:8080/flowable-rest/demo/kadir -u admin:test

The next task is then visible in flowable-task:

Thank you able to get it now.