cancel
Showing results for 
Search instead for 
Did you mean: 

Setting and Retrieving Conditional Expression value

sandeepsapra
Champ in-the-making
Champ in-the-making
Scenario :  I am trying to build a workflow where in a user/author will enter the comments and approver can approve or reject it.  In case of reject flow should go to the user/author again and if approved it will end. Conditional Expression  (variable 'approvalStatus') is given in bpmn file to decide this flow.

Problem  : 
1.) What is way out to set the value of the variable 'approvalStatus'  in the java code so that when approver reject , the flow should go back author.
I am trying to do this way and not sure if it is correct (17610 is my execution ID , false say for a reject case)
runtimeService.setVariable("17610", "approvalDecision",false);

This is just setting value in ACT_RY_VARIABLE table but the flow remains with the approver only

2.) Is my bpmn file correct for the flow I want ?
Please find below the bpmn file:

……………………………………
  <process id="commentsVerification" name="Comments Workflow Verification Process">
      <startEvent id="theStart" />
  
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="enterCommentsTask" />
    <userTask id="enterCommentsTask" name="Enter Comments by Author" >
     <documentation>
        Enter Comments which requires verification
      </documentation>
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>author</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>
    </userTask>
   
    <sequenceFlow id="flow2" sourceRef="enterCommentsTask"  targetRef="verifyCommentsTask" />
     <userTask id="verifyCommentsTask" name="Verify Comments by Approver" >
          <documentation>
        Verify Comments entered by the author. 
      </documentation>
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>approver</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>
    </userTask>
   
    <sequenceFlow id="flow3" sourceRef="verifyCommentsTask" targetRef="approvalDecision" />
     <exclusiveGateway id="approvalDecision" />
    <sequenceFlow id="flow4" sourceRef="approvalDecision" targetRef="enterCommentsTask">
      <conditionExpression>${!approvalStatus}</conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="approvalDecision" targetRef="theEnd">
      <conditionExpression>${approvalStatus}</conditionExpression>
    </sequenceFlow>
    <endEvent id="theEnd" />
  </process>
……………………….


Regards,
Sandeep
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
The taskService.complete method accepts a Map, which u can populate with process variables. That is the way to do this.

sandeepsapra
Champ in-the-making
Champ in-the-making
Thanks for the reply!!! I need to set approvalStatus conditional expression variable.

By populating  process variable , do you mean to say populating conditional expression variables which I have given in the bpmn file , which in my case is approvalStatus ?
……………………………….
<sequenceFlow id="flow3" sourceRef="verifyCommentsTask" targetRef="approvalDecision" />
<exclusiveGateway id="approvalDecision" />
<sequenceFlow id="flow4" sourceRef="approvalDecision" targetRef="enterCommentsTask">
<conditionExpression>${!approvalStatus}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow5" sourceRef="approvalDecision" targetRef="theEnd">
<conditionExpression>${approvalStatus}</conditionExpression>
</sequenceFlow>
…………………………………..

As far as I understand , taskService.complete method accepts a Map.Could you please elaborate its usage - how to set and retrieve conditional expression in that?

Regards,
Sandeep

jbarrez
Star Contributor
Star Contributor
Add the 'approvalStatus' + it's value to the map you pass in the taskService.complete(taskId, map) method. That way, the expression can be resolved.