Passing value to exclusive gateway

2,650 views
Skip to first unread message

priyankas...@gmail.com

unread,
Aug 25, 2015, 3:33:12 AM8/25/15
to camunda BPM users
Hi

I have been creating a project on camunda bpmn in eclipse.While creating the business process diagram , i created a start event , a service task , then an exclusive gateway and then an end event.

I have attached a class with the service task in which i am checking the value of a variable as passed by the user in the form attached with the start event.

But after the value is checked i want to pass true if the value is valid or false if the value is null to the exclusive gateway.

But i can not understand how to pass value from the class attached with the service task to the gateway.

In the class attached with the service task i have used java delegate service method.

Thanks.

webcyberrob

unread,
Aug 25, 2015, 3:57:06 AM8/25/15
to camunda BPM users, priyankas...@gmail.com
Hi,

One way to achieve your outcome is use your service task to set a process instance variable. Then you will be able to test the value of the process variable in your gateway.

You should be able to call setVariable(name, value) on the execution object passed to your delegate class. In your gateway configuration, yiu can then use expression language to test the value.

regards

Rob

priyankas...@gmail.com

unread,
Aug 25, 2015, 4:12:58 AM8/25/15
to camunda BPM users, priyankas...@gmail.com
Hi

I have been actually doing the same thing, but yet can not get the desired results.
I am new to camunda bpmn , can you please suggest any tutorial or guidelines that could be followed to create the complete project in bpmn.

Thanks

webcyberrob

unread,
Aug 25, 2015, 5:57:28 AM8/25/15
to camunda BPM users, priyankas...@gmail.com
Hi,

There is a gret and complete tutorial plus code in the documented guide (link below)


In addition, heres an example in the consulting examples which includes a gateway (see twitter approval demo)...

priyankas...@gmail.com

unread,
Aug 26, 2015, 1:30:43 AM8/26/15
to camunda BPM users, priyankas...@gmail.com
Hi

In the twitter example, they have used a user task and hence are providing the value to the exclusive gateway.
What I need is, that a class must execute through a service task and that class should provide the condition for the exclusive gateway.

For that in the class I set yes/no condition for a variable using java delegate.
I am not understanding how to pass it to the exclusive gateway?

priyankas...@gmail.com

unread,
Aug 26, 2015, 1:56:56 AM8/26/15
to camunda BPM users, priyankas...@gmail.com

webcyberrob

unread,
Aug 26, 2015, 3:38:28 AM8/26/15
to camunda BPM users, priyankas...@gmail.com
Hi,

Ok, the twitter example uses a user task to set the value. The user task or form results in a process variable. The sequence flow out of the gateway can test the value of a process variable.

As I understand your requirement, you want to set the value of a decision variable in a java delegate. Hence you probably have java delegate code like below...

public class MyDelegate implements JavaDelegate {

  public void execute(DelegateExecution execution) throws Exception {
    Integer x = (Integer) execution.getVariable("x");

    // apply business logic and setup the value of a process variable to be used as a decision variable.
    if (x > 100)
execution.setVariable("approved","TRUE");
    else
       execution.setVariable("approved","FALSE");
    
  }

}

Now you need to test the value of the process variable 'approved' in the sequence flows out of your exclusive gateway. Hence in the eclipse IDE, select a sequence flow out of the gateway. In the properties tab, enter the following in the condition text box;

${approved == 'TRUE'}

in the alternate sequence flow, do the same however the condition will be

${approved == 'FALSE'}

This is using expression language as flow conditions. You can read more at the link below...


Hope this helps,

regards

Rob

priyankas...@gmail.com

unread,
Aug 26, 2015, 4:51:50 AM8/26/15
to camunda BPM users, priyankas...@gmail.com
Hi

I am doing the same as suggested by you. But I am getting the following error after deploying the application:

Cannot instantiate process definition : condition expression returns non-boolean: result has class java.lang.String and not java.lang.Boolean

I am not getting the reason for the above error.

priyankas...@gmail.com

unread,
Aug 26, 2015, 5:01:06 AM8/26/15
to camunda BPM users, priyankas...@gmail.com
Hey

The code worked out.

Thanks a lot for all your support. :)

Regards,
Priyanka

Reply all
Reply to author
Forward
0 new messages