cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing ActivityExecution in Business Rules

mortezaadi
Champ in-the-making
Champ in-the-making
Can i access executionContext in Business rule.

my goal is to write some rules based on process variables.

for instance

when context.getVariable('amount') > 100
then context.setvariable('accepetd',true)

If possible how can i do that?
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

The activiti user guide says:
http://www.activiti.org/userguide/#bpmnBusinessRuleTask

For the input variable definition a list of process variables can be defined separated by a comma.

Regards
Martin

mortezaadi
Champ in-the-making
Champ in-the-making
Yeah and its simply applying rules on those variable if the conditions meet the rule criteria.
however you cannot write a rule for primitive variables!!. So de default behavior doesn't helpt me much.
for instance how can you say in Rule that

when variable x is grather than 100 then ….

I found the solution anyway i extended BusinessRuleBehaviour and put the execution Context in the knowledgebase before firing rules and now i can write a rule such as

import org.activiti.engine.impl.pvm.delegate.ActivityExecution

rule "TestExecution"
      dialect "java"
  when
      execution : ActivityExecution(getVariable("v_v") == "tech")
  then
      execution.setVariable("v_v2",200);
      System.out.println("After Then XXX");
end