cancel
Showing results for 
Search instead for 
Did you mean: 

A little help on the routing of the gateways needed

d00d
Champ in-the-making
Champ in-the-making
Hi,

i have a simple demo process



<?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" 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://activiti.org/bpmn20" id="definitions">
  <process id="financialReport" name="Monthly financial report reminder process" isExecutable="true">
    <startEvent id="theStart">
      <extensionElements>
        <activiti:formProperty id="requestApproved" name="requestApproved" type="boolean" expression="TRUE" variable="TRUE" writable="false">
          <activiti:value id="requestApproved" name="TRUE"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </startEvent>
    <userTask id="verifyReportTask" name="Process B" activiti:candidateGroups="management">
      <documentation>Verify monthly financial report composed by the accountancy department.
              This financial report is going to be sent to all the company shareholders.</documentation>
    </userTask>
    <endEvent id="theEnd"></endEvent>
    <userTask id="usertask1" name="Process A"></userTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow5" sourceRef="exclusivegateway1" targetRef="usertask1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${requestApproved == "true"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="exclusivegateway1" targetRef="verifyReportTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${requestApproved == "false"}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow7" sourceRef="usertask1" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="verifyReportTask" targetRef="exclusivegateway2"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="exclusivegateway2" targetRef="theEnd"></sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="theStart" targetRef="exclusivegateway1"></sequenceFlow>
  </process>

</definitions>



I am currently trying to route the process flow according on a local variable that i declared within the example.java code where the workflow is being executed (claim and execute tasks and so on). I declared a


boolean requestApproved = true;


within my java class that i want to be checked for at the gateway and route the flow accordingly. But i get the following error message:

Exception in thread "main" org.activiti.engine.ActivitiException: Unknown property used in expression: ${requestApproved == "true"}


What's wrong with my code? Any ideas?
5 REPLIES 5

smirzai
Champ on-the-rise
Champ on-the-rise
have you passed the variable to activiti  ? maybe you can also include your example.java

d00d
Champ in-the-making
Champ in-the-making
No actually i haven't passed it. My code is basically from the 10 minute tutorial. I find it very hard to make the first steps into the world of activiti to be honest, thus i did not know that i had to pass the variable to activiti nor how i do this. Any example code would be helpful.

<code>

public class activitiExample{
 
public static void main(String[] args) {
 
  boolean requestApproved = true;
             
  // Create process engine
     ProcessEngine processEngine = ProcessEngineConfiguration
       .createStandaloneProcessEngineConfiguration()
       .buildProcessEngine();
    
     // Get activiti services
     RepositoryService repositoryService = processEngine.getRepositoryService();
     RuntimeService runtimeService = processEngine.getRuntimeService();
     TaskService taskService = processEngine.getTaskService();
     FormService formService = processEngine.getFormService();
    
     // Deployment of process definitions
     repositoryService.createDeployment()
       .addClasspathResource("diagrams/FinancialReportProcess.bpmn20.xml")
       .deploy();
 
     // Start process instance
     String procId = runtimeService.startProcessInstanceByKey("financialReport").getId();
     String procDefId = runtimeService.startProcessInstanceByKey("financialReport").getProcessDefinitionId();
    
     // Get first task
             
     List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("accountancy").list();
     for (Task task : tasks) {
       System.out.println("Following task is available for accountancy group: " + task.getName());
       // claim it
       taskService.claim(task.getId(), "fozzie");
      
     }
    
     // Verify Fozzie can now retrieve the task
     tasks = taskService.createTaskQuery().taskAssignee("fozzie").list();
     for (Task task : tasks) {
       System.out.println("Task for fozzie: " + task.getName());
      
       // Complete the task
       taskService.complete(task.getId());
      
     }
    
     System.out.println("Number of tasks for fozzie: "
             + taskService.createTaskQuery().taskAssignee("fozzie").count());
    
     // Retrieve and claim the second task
     tasks = taskService.createTaskQuery().taskCandidateGroup("management").list();
     for (Task task : tasks) {
       System.out.println("Following task is available for accountancy group: " + task.getName());
       taskService.claim(task.getId(), "kermit");
    
     }
              
     // Completing the second task ends the process
     for (Task task : tasks) {
       taskService.complete(task.getId());
     }
    
   }


}
</code>

jbarrez
Star Contributor
Star Contributor
But the exception is pretty clear, no?

"Unknown property used in expression: ${requestApproved == "true"}"

It can't find the property you used to go either left or right in the process.

d00d
Champ in-the-making
Champ in-the-making
@jbarrez: Indeed the error message is very clear. My problem is that i don't have a clue how to parse the variable requestApproved from the very first line of my java code into the activiti process lifecycle…

jbarrez
Star Contributor
Star Contributor
runtimeService.startProcessInstanceByKey("financialReport") needs to have the variables … needs to be  runtimeService.startProcessInstanceByKey("financialReport", variables) where variables is a Map<String, Object>