How can we get / set InputParameter and OutputParameter in a Task

How can we get / set InputParameter and OutputParameter in a Task

Background
  • We like to have a Workflow driven feature
Plan
  • Each UserTask is responsible for collecting and saving data.
  • OutputParameter, retrieved by the code and used to update the data property, such like status.
  • InputParameter, retrieved by the code and determine which variables current UserTask needs, such like the variable for SequenceFlow.

Example

<bpmn2:userTask id="UserTask_InputCaseInfo" name="PENDING">
  <bpmn2:extensionElements>
    <camunda:inputOutput>
      <camunda:inputParameter name="amount" />
      <camunda:outputParameter name="status">COMPLETE_CASE_INFO</camunda:outputParameter>
    </camunda:inputOutput>
  </bpmn2:extensionElements>
  <bpmn2:incoming>SequenceFlow_InputCaseInfo</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_RegisterCase</bpmn2:outgoing>
</bpmn2:userTask>
Question
  • Is this the right way to do this?
  • If yes.
    • How can we get / set InputParameter and OutputParameter in a Task?
    • We tried RuntimeService.getVariablesLocal, RuntimeService.getVariables, TaskService.getVariablesLocal, TaskService.getVariables. No luck.
  • If no, any advice is appreciated.
1 Like

Input parameters are not available as local variables on the task itself, but as local variables of the execution that is referenced by the task. So runtimeService.getVariablesLocal(task.getExecutionId()); should work.

Sorry, we just tried runtimeService.getVariablesLocal(), We only got the variables we set via code. No xml defined InputParameter & OutputParameter were returned. :frowning:

Could you provide a test case for this behavior please?

Can I provide the bpmn file instead?

It would be best to have at least the BPMN file and the code that accesses the variables, along with a description where in the process this code is invoked.

Thanks for your reply. I will prepare these descriptions and post it later. Thanks again.

Here comes the bpmn and groovy code we are using, but failed to get/set the output and input parameters.

Any help would be appreciated.

Details go below

inputOutput setup
<bpmn2:userTask id="UserTask_InputCaseInfo" name="Input Case Info">
  <bpmn2:extensionElements>
    <camunda:inputOutput>
      <camunda:inputParameter name="amount" />
      <camunda:outputParameter name="status">COMPLETE_CASE_INFO</camunda:outputParameter>
    </camunda:inputOutput>
  </bpmn2:extensionElements>
  <bpmn2:incoming>SequenceFlow_InputCaseInfo</bpmn2:incoming>
  <bpmn2:outgoing>SequenceFlow_RegisterCase</bpmn2:outgoing>
</bpmn2:userTask>
Start Process Instance By Key
    /**
     * Starts a new process instance in the latest version of the process definition with the given key.
     * @param processDefinitionKey: Key of process definition, cannot be null.
     * @param businessKey: A key that uniquely identifies the process instance in the context of the given process definition.
     * @param processInstanceVariables: The variables to pass, can be null.
     * @return map: Elements reference to executionCollectClosure.
     */
    static def startProcessInstanceByKey(processDefinitionKey, businessKey, processInstanceVariables) {
    def result

    if (businessKey == null || businessKey == "") {
        result = runtimeService.startProcessInstanceByKey(processDefinitionKey, processInstanceVariables).executionEntity.collect(executionCollectClosure)
    } else {
        result = runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, processInstanceVariables).collect(executionCollectClosure)
    }

    return getFirstElement(result)
}
Query Task
static def queryTask(processInstanceId) {
    def result = taskService.createTaskQuery().processInstanceId(processInstanceId).list().collect(taskCollectClosure)

    return result
}
Get Execution Variables
/**
 * Gets all variable values that are defined in the execution scope, without taking outer scopes into account.
 * @param executionId: Id of execution, cannot be null.
 * @param isLocal: Boolean, if it is true then will not look in outer scopes.
 * @return
 */
static def getExecutionVariables(executionId, isLocal) {
    return isLocal ? runtimeService.getVariablesLocal(executionId) : runtimeService.getVariables(executionId)
}
Get Task Variables
/**
 * Gets all variables and search in the task scope and if available also the execution scopes.
 * @param taskId: The string of the task id.
 * @param isLocal: Boolean, if it is true search only in the task scope.
 * @return The map instance.
 */
static def getTaskVariables(taskId, isLocal) {
    return isLocal ? taskService.getVariablesLocal(taskId) : taskService.getVariables(taskId)
}
Main Content of bpmn file
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_Qr4CsJjdEeOi2_UbKTmDjw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
  <bpmn2:collaboration id="Collaboration_CriminalPublicProsecution">
    <bpmn2:participant id="Participant_CriminalPublicProsecution" name="Criminal Public Prosecution" processRef="CriminalPublicProsecutionProcess" />
  </bpmn2:collaboration>
  <bpmn2:process id="CriminalPublicProsecutionProcess" name="Criminal Public Prosecution" isExecutable="true">
    <bpmn2:laneSet>
      <bpmn2:lane id="Lane_CaseRegister" name="Case Register">
        <bpmn2:flowNodeRef>StartEvent_CriminalPublicProsecution</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>Task_AcceptOnline</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_InputCaseInfo</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>EndEvent_CriminalPublicProsecution_OnlineReturned</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_RegisterCase</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_ReturnCaseDueToServiceFailed</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_TransferCase</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_RetransferCase</bpmn2:flowNodeRef>
      </bpmn2:lane>
      <bpmn2:lane id="Lane_CaseTrial" name="Criminal Court">
        <bpmn2:flowNodeRef>UserTask_CourtDivisionAccept</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_RequestReassignment</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>ExclusiveGateway_ServeCase</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_ServeCase</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>ExclusiveGateway_AcceptCaseAssignment</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_AcceptCaseAssignment</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_AssignCase</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>ExclusiveGateway_CourtDivisionAccept</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>SubProcess_CaseApplicableProcedureChange</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_ScheduleTrial</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_CreateTrialOrganization</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_CompleteJudgmentDocument</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_RequestJudgmentDocumentSignOff</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>SubProcess_JudgmentDocumentSignOffProcess</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_InputCaseCloseInfo</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>EndEvent_CriminalPublicProsecution_CaseClosed</bpmn2:flowNodeRef>
        <bpmn2:flowNodeRef>UserTask_CloseCase</bpmn2:flowNodeRef>
      </bpmn2:lane>
    </bpmn2:laneSet>
    <bpmn2:startEvent id="StartEvent_CriminalPublicProsecution" name="Public Prosecution">
      <bpmn2:extensionElements>
        <camunda:formData>
          <camunda:formField id="initiator" label="Initiator" type="long">
            <camunda:validation>
              <camunda:constraint name="required" />
            </camunda:validation>
          </camunda:formField>
          <camunda:formField id="caseDocNo" label="Case Doc No" type="string">
            <camunda:validation>
              <camunda:constraint name="required" />
            </camunda:validation>
          </camunda:formField>
          <camunda:formField id="caseNo" label="Case No" type="long">
            <camunda:validation>
              <camunda:constraint name="required" />
            </camunda:validation>
          </camunda:formField>
        </camunda:formData>
      </bpmn2:extensionElements>
      <bpmn2:outgoing>SequenceFlow_AcceptOnline</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:task id="Task_AcceptOnline" name="Accept Online">
      <bpmn2:incoming>SequenceFlow_AcceptOnline</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_InputCaseInfo</bpmn2:outgoing>
    </bpmn2:task>
    <bpmn2:userTask id="UserTask_InputCaseInfo" name="Input Case Info">
      <bpmn2:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="amount" />
          <camunda:outputParameter name="status">COMPLETE_CASE_INFO</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_InputCaseInfo</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_RegisterCase</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:endEvent id="EndEvent_CriminalPublicProsecution_OnlineReturned" name="Online Returned">
      <bpmn2:incoming>SequenceFlow_ReturnOnlineDueToServiceFailed</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_ReturnOnlineDueToCheckFailed</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:userTask id="UserTask_RegisterCase" name="Register Case">
      <bpmn2:incoming>SequenceFlow_RegisterCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_TransferCase</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_ReturnOnlineDueToCheckFailed</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_ReturnCaseDueToServiceFailed" name="Service Failed">
      <bpmn2:incoming>SequenceFlow_ReturnCaseDueToServiceFailed</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_ReturnOnlineDueToServiceFailed</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_TransferCase" name="Transfer Case">
      <bpmn2:incoming>SequenceFlow_TransferCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CourtDivisionAccept</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_RetransferCase" name="Retransfer Case">
      <bpmn2:incoming>SequenceFlow_RetransferCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CourtDivisionAcceptAfterRetransfer</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="SequenceFlow_AcceptOnline" sourceRef="StartEvent_CriminalPublicProsecution" targetRef="Task_AcceptOnline" />
    <bpmn2:sequenceFlow id="SequenceFlow_InputCaseInfo" sourceRef="Task_AcceptOnline" targetRef="UserTask_InputCaseInfo" />
    <bpmn2:sequenceFlow id="SequenceFlow_RegisterCase" sourceRef="UserTask_InputCaseInfo" targetRef="UserTask_RegisterCase" />
    <bpmn2:sequenceFlow id="SequenceFlow_ReturnOnlineDueToCheckFailed" name="" sourceRef="UserTask_RegisterCase" targetRef="EndEvent_CriminalPublicProsecution_OnlineReturned">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${onlineRejected == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_ReturnOnlineDueToServiceFailed" sourceRef="UserTask_ReturnCaseDueToServiceFailed" targetRef="EndEvent_CriminalPublicProsecution_OnlineReturned" />
    <bpmn2:sequenceFlow id="SequenceFlow_TransferCase" sourceRef="UserTask_RegisterCase" targetRef="UserTask_TransferCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${onlineRejected == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_ReturnCaseDueToServiceFailed" name="Service Failed" sourceRef="ExclusiveGateway_ServeCase" targetRef="UserTask_ReturnCaseDueToServiceFailed">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseServed == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_CourtDivisionAccept" sourceRef="UserTask_TransferCase" targetRef="UserTask_CourtDivisionAccept" />
    <bpmn2:sequenceFlow id="SequenceFlow_RetransferCase" name="Retransfer Case" sourceRef="ExclusiveGateway_CourtDivisionAccept" targetRef="UserTask_RetransferCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${courtDivisionAccepted == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_CourtDivisionAcceptAfterRetransfer" sourceRef="UserTask_RetransferCase" targetRef="UserTask_CourtDivisionAccept" />
    <bpmn2:userTask id="UserTask_CourtDivisionAccept" name="Court Division Accept">
      <bpmn2:incoming>SequenceFlow_CourtDivisionAcceptAfterRetransfer</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_CourtDivisionAccept</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CourtDivisionAcceptGateway</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_RequestReassignment" name="Request Reassignment">
      <bpmn2:incoming>SequenceFlow_RequestReassignment</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_AcceptCaseAssignmentAfterReassignment</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:exclusiveGateway id="ExclusiveGateway_ServeCase" name="Serve Case">
      <bpmn2:incoming>SequenceFlow_ServeCaseGateway</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_ReturnCaseDueToServiceFailed</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_CreateTrialOrganization</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:userTask id="UserTask_ServeCase" name="Serve Case">
      <bpmn2:incoming>SequenceFlow_ServeCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_ServeCaseGateway</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:exclusiveGateway id="ExclusiveGateway_AcceptCaseAssignment" name="Accept Case Assignment">
      <bpmn2:incoming>SequenceFlow_AcceptCaseAssignmentGateway</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_RequestReassignment</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_ServeCase</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:userTask id="UserTask_AcceptCaseAssignment" name="Accept Case Assignment">
      <bpmn2:incoming>SequenceFlow_AcceptCaseAssignmentAfterReassignment</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_AcceptCaseAssignment</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_AcceptCaseAssignmentGateway</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_AssignCase" name="Assign Case">
      <bpmn2:incoming>SequenceFlow_AssignCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_AcceptCaseAssignment</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:exclusiveGateway id="ExclusiveGateway_CourtDivisionAccept" name="Court Division Accept">
      <bpmn2:incoming>SequenceFlow_CourtDivisionAcceptGateway</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_AssignCase</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_RetransferCase</bpmn2:outgoing>
    </bpmn2:exclusiveGateway>
    <bpmn2:subProcess id="SubProcess_CaseApplicableProcedureChange" name="Case Applicable Procedure Change">
      <bpmn2:incoming>SequenceFlow_RequestCaseApplicableProcedureChangeBeforeCreateJudicialOrganization</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_RequestCaseApplicableProcedureChangeBeforeTrialSchedule</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeCreateJudicialOrganization</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeTrialSchedule</bpmn2:outgoing>
      <bpmn2:startEvent id="StartEvent_ChangeCaseApplicableProcedure" name="Start">
        <bpmn2:outgoing>SequenceFlow_CaseApplicableProcedureChange</bpmn2:outgoing>
      </bpmn2:startEvent>
      <bpmn2:endEvent id="EndEvent_ChangeCaseApplicableProcedure" name="End">
        <bpmn2:incoming>SequenceFlow_CaseApplicableProcedureChangeRejected</bpmn2:incoming>
        <bpmn2:incoming>SequenceFlow_CaseApplicableProcedureChanged</bpmn2:incoming>
      </bpmn2:endEvent>
      <bpmn2:exclusiveGateway id="ExclusiveGateway_ChangeCaseApplicableProcedure" name="Change">
        <bpmn2:incoming>SequenceFlow_ChangeCaseApplicableProcedureGateway</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_CaseApplicableProcedureChangeRejected</bpmn2:outgoing>
        <bpmn2:outgoing>SequenceFlow_CaseApplicableProcedureChangeApproved</bpmn2:outgoing>
      </bpmn2:exclusiveGateway>
      <bpmn2:userTask id="UserTask_CaseApplicableProcedureChangeCheck" name="Check">
        <bpmn2:incoming>SequenceFlow_CaseApplicableProcedureChange</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_ChangeCaseApplicableProcedureGateway</bpmn2:outgoing>
      </bpmn2:userTask>
      <bpmn2:sequenceFlow id="SequenceFlow_CaseApplicableProcedureChange" sourceRef="StartEvent_ChangeCaseApplicableProcedure" targetRef="UserTask_CaseApplicableProcedureChangeCheck" />
      <bpmn2:sequenceFlow id="SequenceFlow_CaseApplicableProcedureChangeRejected" name="Rejected" sourceRef="ExclusiveGateway_ChangeCaseApplicableProcedure" targetRef="EndEvent_ChangeCaseApplicableProcedure">
        <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseApplicableProcedureChangeApproved == false}</bpmn2:conditionExpression>
      </bpmn2:sequenceFlow>
      <bpmn2:sequenceFlow id="SequenceFlow_ChangeCaseApplicableProcedureGateway" sourceRef="UserTask_CaseApplicableProcedureChangeCheck" targetRef="ExclusiveGateway_ChangeCaseApplicableProcedure" />
      <bpmn2:sequenceFlow id="SequenceFlow_CaseApplicableProcedureChanged" sourceRef="Task_CaseApplicableProcedureChanged" targetRef="EndEvent_ChangeCaseApplicableProcedure" />
      <bpmn2:sequenceFlow id="SequenceFlow_CaseApplicableProcedureChangeApproved" name="Approved" sourceRef="ExclusiveGateway_ChangeCaseApplicableProcedure" targetRef="Task_CaseApplicableProcedureChanged">
        <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseApplicableProcedureChangeApproved == true}</bpmn2:conditionExpression>
      </bpmn2:sequenceFlow>
      <bpmn2:task id="Task_CaseApplicableProcedureChanged" name="Changed">
        <bpmn2:incoming>SequenceFlow_CaseApplicableProcedureChangeApproved</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_CaseApplicableProcedureChanged</bpmn2:outgoing>
      </bpmn2:task>
    </bpmn2:subProcess>
    <bpmn2:userTask id="UserTask_ScheduleTrial" name="Schedule Trial">
      <bpmn2:incoming>SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeTrialSchedule</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_ScheduleTrial</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CompleteJudgmentDocument</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_RequestCaseApplicableProcedureChangeBeforeTrialSchedule</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_CreateTrialOrganization" name="Create Trial Organization">
      <bpmn2:incoming>SequenceFlow_CreateTrialOrganization</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeCreateJudicialOrganization</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_ScheduleTrial</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_RequestCaseApplicableProcedureChangeBeforeCreateJudicialOrganization</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="SequenceFlow_CourtDivisionAcceptGateway" sourceRef="UserTask_CourtDivisionAccept" targetRef="ExclusiveGateway_CourtDivisionAccept" />
    <bpmn2:sequenceFlow id="SequenceFlow_RequestReassignment" name="Request Reassignment" sourceRef="ExclusiveGateway_AcceptCaseAssignment" targetRef="UserTask_RequestReassignment">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseAssignmentAccepted == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_AcceptCaseAssignmentAfterReassignment" sourceRef="UserTask_RequestReassignment" targetRef="UserTask_AcceptCaseAssignment" />
    <bpmn2:sequenceFlow id="SequenceFlow_ServeCaseGateway" sourceRef="UserTask_ServeCase" targetRef="ExclusiveGateway_ServeCase" />
    <bpmn2:sequenceFlow id="SequenceFlow_CreateTrialOrganization" name="Served" sourceRef="ExclusiveGateway_ServeCase" targetRef="UserTask_CreateTrialOrganization">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseServed == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_ServeCase" name="Accpeted" sourceRef="ExclusiveGateway_AcceptCaseAssignment" targetRef="UserTask_ServeCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${caseAssignmentAccepted == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_AcceptCaseAssignmentGateway" sourceRef="UserTask_AcceptCaseAssignment" targetRef="ExclusiveGateway_AcceptCaseAssignment" />
    <bpmn2:sequenceFlow id="SequenceFlow_AcceptCaseAssignment" sourceRef="UserTask_AssignCase" targetRef="UserTask_AcceptCaseAssignment" />
    <bpmn2:sequenceFlow id="SequenceFlow_AssignCase" name="Accpeted" sourceRef="ExclusiveGateway_CourtDivisionAccept" targetRef="UserTask_AssignCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${courtDivisionAccepted == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_CompleteJudgmentDocument" sourceRef="UserTask_ScheduleTrial" targetRef="UserTask_CompleteJudgmentDocument">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestCaseApplicableProcedureChange == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_RequestCaseApplicableProcedureChangeBeforeCreateJudicialOrganization" name="Before Create Judicial Organization" sourceRef="UserTask_CreateTrialOrganization" targetRef="SubProcess_CaseApplicableProcedureChange">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestCaseApplicableProcedureChange == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_RequestCaseApplicableProcedureChangeBeforeTrialSchedule" name="Before Trial Schedule" sourceRef="UserTask_ScheduleTrial" targetRef="SubProcess_CaseApplicableProcedureChange">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestCaseApplicableProcedureChange == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeCreateJudicialOrganization" name="Completed Before Create Judicial Organization" sourceRef="SubProcess_CaseApplicableProcedureChange" targetRef="UserTask_CreateTrialOrganization">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[${requestCaseApplicableProcedureChangeFrom == "CASE_SERVED"}]]></bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_RequestCaseApplicableProcedureChangeCompletedBeforeTrialSchedule" name="Completed Before Trial Schedule" sourceRef="SubProcess_CaseApplicableProcedureChange" targetRef="UserTask_ScheduleTrial">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[${requestCaseApplicableProcedureChangeFrom == "TRIAL_ORGANIZATION_CREATED"}]]></bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_ScheduleTrial" sourceRef="UserTask_CreateTrialOrganization" targetRef="UserTask_ScheduleTrial">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestCaseApplicableProcedureChange == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:userTask id="UserTask_CompleteJudgmentDocument" name="Complete Judgment Document">
      <bpmn2:extensionElements>
        <camunda:formData>
          <camunda:formField id="requestReassign" label="Request Reassign" type="boolean" defaultValue="false" />
        </camunda:formData>
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_CompleteJudgmentDocument</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_RequestJudgmentDocumentSignOff</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:userTask id="UserTask_RequestJudgmentDocumentSignOff" name="Request Judgment Document SignOff">
      <bpmn2:incoming>SequenceFlow_RequestJudgmentDocumentSignOff</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_JudgmentDocumentSignOffProcess</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:sequenceFlow id="SequenceFlow_InputCaseCloseInfo" sourceRef="SubProcess_JudgmentDocumentSignOffProcess" targetRef="UserTask_InputCaseCloseInfo">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[${requestJudgmentDocumentSignOffFrom == "JUDGMENT_DOCUMENT_SIGN_OFF_REQUESTED"}]]></bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_CloseCase" sourceRef="UserTask_InputCaseCloseInfo" targetRef="UserTask_CloseCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestJudgmentDocumentSignOff == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_CaseClosed" sourceRef="UserTask_CloseCase" targetRef="EndEvent_CriminalPublicProsecution_CaseClosed">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestJudgmentDocumentSignOff == false}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:subProcess id="SubProcess_JudgmentDocumentSignOffProcess" name="Judgment Document SignOff Process">
      <bpmn2:incoming>SequenceFlow_JudgmentDocumentSignOffProcess</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_JudgmentDocumentRerequestSignOffBeforeInputCaseCloseInfo</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_JudgmentDocumentRerequestSignOffBeforeCloseCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_InputCaseCloseInfo</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeInputCaseCloseInfo</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeCloseCase</bpmn2:outgoing>
      <bpmn2:startEvent id="StartEvent_SignOffJudgmentDocument" name="Start">
        <bpmn2:outgoing>SequenceFlow_SignOffJudgmentDocument</bpmn2:outgoing>
      </bpmn2:startEvent>
      <bpmn2:endEvent id="EndEvent_SignOffJudgmentDocument" name="End">
        <bpmn2:incoming>SequenceFlow_JudgmentDocumentSignedOff</bpmn2:incoming>
      </bpmn2:endEvent>
      <bpmn2:exclusiveGateway id="ExclusiveGateway_SignOffJudgmentDocument" name="SignOff">
        <bpmn2:incoming>SequenceFlow_SignOffJudgmentDocumentGateway</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_JudgmentDocumentSignOffRejected</bpmn2:outgoing>
        <bpmn2:outgoing>SequenceFlow_JudgmentDocumentSignOffApproved</bpmn2:outgoing>
      </bpmn2:exclusiveGateway>
      <bpmn2:userTask id="UserTask_SignOffJudgmentDocument" name="SignOff">
        <bpmn2:incoming>SequenceFlow_SignOffJudgmentDocument</bpmn2:incoming>
        <bpmn2:incoming>SequenceFlow_JudgmentDocumentSignOffAfterRevise</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_SignOffJudgmentDocumentGateway</bpmn2:outgoing>
      </bpmn2:userTask>
      <bpmn2:task id="Task_JudgmentDocumentSignedOff" name="Signed Off">
        <bpmn2:incoming>SequenceFlow_JudgmentDocumentSignOffApproved</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_JudgmentDocumentSignedOff</bpmn2:outgoing>
      </bpmn2:task>
      <bpmn2:sequenceFlow id="SequenceFlow_SignOffJudgmentDocument" sourceRef="StartEvent_SignOffJudgmentDocument" targetRef="UserTask_SignOffJudgmentDocument" />
      <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentSignOffRejected" name="Rejected" sourceRef="ExclusiveGateway_SignOffJudgmentDocument" targetRef="UserTask_ReviseJudgmentDocument">
        <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${judgmentDocumentSignOffApproved == false}</bpmn2:conditionExpression>
      </bpmn2:sequenceFlow>
      <bpmn2:sequenceFlow id="SequenceFlow_SignOffJudgmentDocumentGateway" sourceRef="UserTask_SignOffJudgmentDocument" targetRef="ExclusiveGateway_SignOffJudgmentDocument" />
      <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentSignOffApproved" name="Approved" sourceRef="ExclusiveGateway_SignOffJudgmentDocument" targetRef="Task_JudgmentDocumentSignedOff">
        <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${judgmentDocumentSignOffApproved == true}</bpmn2:conditionExpression>
      </bpmn2:sequenceFlow>
      <bpmn2:userTask id="UserTask_ReviseJudgmentDocument" name="Revise Judgment Document">
        <bpmn2:incoming>SequenceFlow_JudgmentDocumentSignOffRejected</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_RerequestJudgmentDocumentSignOff</bpmn2:outgoing>
      </bpmn2:userTask>
      <bpmn2:userTask id="UserTask_RerequestJudgmentDocumentSignOff" name="Rerequest Judgment Document SignOff">
        <bpmn2:incoming>SequenceFlow_RerequestJudgmentDocumentSignOff</bpmn2:incoming>
        <bpmn2:outgoing>SequenceFlow_JudgmentDocumentSignOffAfterRevise</bpmn2:outgoing>
      </bpmn2:userTask>
      <bpmn2:sequenceFlow id="SequenceFlow_RerequestJudgmentDocumentSignOff" sourceRef="UserTask_ReviseJudgmentDocument" targetRef="UserTask_RerequestJudgmentDocumentSignOff" />
      <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentSignOffAfterRevise" sourceRef="UserTask_RerequestJudgmentDocumentSignOff" targetRef="UserTask_SignOffJudgmentDocument" />
      <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentSignedOff" sourceRef="Task_JudgmentDocumentSignedOff" targetRef="EndEvent_SignOffJudgmentDocument" />
    </bpmn2:subProcess>
    <bpmn2:sequenceFlow id="SequenceFlow_RequestJudgmentDocumentSignOff" sourceRef="UserTask_CompleteJudgmentDocument" targetRef="UserTask_RequestJudgmentDocumentSignOff" />
    <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentSignOffProcess" sourceRef="UserTask_RequestJudgmentDocumentSignOff" targetRef="SubProcess_JudgmentDocumentSignOffProcess" />
    <bpmn2:userTask id="UserTask_InputCaseCloseInfo" name="Input Case Close Info">
      <bpmn2:incoming>SequenceFlow_InputCaseCloseInfo</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeInputCaseCloseInfo</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CloseCase</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_JudgmentDocumentRerequestSignOffBeforeInputCaseCloseInfo</bpmn2:outgoing>
    </bpmn2:userTask>
    <bpmn2:endEvent id="EndEvent_CriminalPublicProsecution_CaseClosed" name="Case Closed">
      <bpmn2:incoming>SequenceFlow_CaseClosed</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentRerequestSignOffBeforeInputCaseCloseInfo" name="Rerequest SignOff Before Input Case Close Info" sourceRef="UserTask_InputCaseCloseInfo" targetRef="SubProcess_JudgmentDocumentSignOffProcess">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestJudgmentDocumentSignOff == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeInputCaseCloseInfo" name="Signed Off Before Input Case Close Info" sourceRef="SubProcess_JudgmentDocumentSignOffProcess" targetRef="UserTask_InputCaseCloseInfo">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[${requestJudgmentDocumentSignOffFrom == "JUDGMENT_DOCUMENT_SIGNED_OFF"}]]></bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentRerequestSignOffBeforeCloseCase" name="Rerequest SignOff Before Close Case" sourceRef="UserTask_CloseCase" targetRef="SubProcess_JudgmentDocumentSignOffProcess">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">${requestJudgmentDocumentSignOff == true}</bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:sequenceFlow id="SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeCloseCase" name="Signed Off Before Close Case" sourceRef="SubProcess_JudgmentDocumentSignOffProcess" targetRef="UserTask_CloseCase">
      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[${requestJudgmentDocumentSignOffFrom == "CASE_CLOSE_INFO_INPUT_COMPLETED"}]]></bpmn2:conditionExpression>
    </bpmn2:sequenceFlow>
    <bpmn2:userTask id="UserTask_CloseCase" name="Close Case">
      <bpmn2:incoming>SequenceFlow_CloseCase</bpmn2:incoming>
      <bpmn2:incoming>SequenceFlow_JudgmentDocumentRerequestSignedOffBeforeCloseCase</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_CaseClosed</bpmn2:outgoing>
      <bpmn2:outgoing>SequenceFlow_JudgmentDocumentRerequestSignOffBeforeCloseCase</bpmn2:outgoing>
    </bpmn2:userTask>
  </bpmn2:process>
</bpmn2:definitions>

Hi,

  1. How do you verify that the variables are not accessible? Is the returned map empty or does it contain null values for the mapped value?
  2. Could you describe the interactions with the process instance after you start it? Or stated differently, when in the lifecycle of the process instance do you call the getExecutionVariables and getTaskVariables methods? What are the arguments to these method invocations?

If you can, writing a simple isolated test case (process with a single task with io mapping) might help in understanding how input/output mappings work.

Cheers,
Thorben

Hi thorben,

Thanks for your response.

How do you verify that the variables are not accessible? Is the returned map empty or does it contain null values for the mapped value?

  • When I used ```
    runtimeService.getVariablesLocal(executionId)

> Could you describe the interactions with the process instance after you start it? Or stated differently, when in the lifecycle of the process instance do you call the getExecutionVariables and getTaskVariables methods? What are the arguments to these method invocations?

- When I started the process and current node is a UserTask which the input and output parameter is setup. I tried 
    - ```runtimeService.getVariablesLocal(executionId)```
    - ```runtimeService.getVariables(executionId)```
    - ```taskService.getVariables(executionId)```
    - ```taskService.getVariables(executionId)```
to retrieve the data. The returned result is an **empty map**.

Any update on this question, please?

I just found how it worked by myself.

For example, I have below workflow.

Workflow Definition

Start Event → User Task 1 → User Task 2 → End Event

Task Defintion

  • User Task 1
    • Input Parameter: inputData.
    • Output Parameter: status. Value: NEW.
  • User Task 2
    • Input Parameter: dateCreated.
    • Output Parameter: status. Value: ADDED.

Steps

  1. Start this workflow
  2. Current task: User Task 1
  3. Result of runtimeService.getVariables() or taskService.getVariables() is a map that contains 1 item.
    1. Key: inputData, value: null.
  4. Complete User Task 1
  5. Current task: User Task 2
  6. Result of runtimeService.getVariables() or taskService.getVariables() is a map that contains 2 items.
    1. Key: dateCreated, value is null.
    2. Key: status, value: NEW.

Conclusion

The output parameter of a task will be retrieved after this task is complete.

Question

How can I get the output parameter of the last user task since when it’s done the process will be finished. Via historyService to get the historical data?

I’m glad you figured it out :slight_smile:
Yes, you can use the history queries to access variables once the instance is finished.

Hello @thorben , @kyle

I’m not able to get inputParameter value in TaskListener (task create event). What am I doing wrong ?

Here is my cmmn snippet -
<cmmn:humanTask name=“Rating” id=“HT_2” camunda:assignee=“demo”>
cmmn:extensionElements
camunda:inputOutput
<camunda:inputParameter name=“x”>6</camunda:inputParameter>
</camunda:inputOutput>
</cmmn:extensionElements>
</cmmn:humanTask>

Here is my TaskListener implements TaskListener {
public void notify(DelegateTask delegateTask) {
DelegateCaseExecution execution = delegateTask.getCaseExecution();
String x = (String) execution.getVariable(“x”); // returns null
x = (String) execution.getVariableLocal(“x”); // returns null too.
x = runtimeService.getVariablesLocal(task.getExecutionId()); // throws error //execution does not exist
}
}