15

Is it possible to retrieve rule name in the then clause of drool rule?

rule "A"
    when
        ---
    then
        // something that outputs "A"

Thanks.

Manish Mulani
  • 7,125
  • 9
  • 43
  • 45

2 Answers2

35

Yes, in then clause you may use expression:

drools.getRule().getName()
Cyril Sochor
  • 692
  • 6
  • 9
4

As Cyril said, you can get the rule name in the then clause by calling drools.getRule().getName() of the drools rule.

Just a little more info, you can check the getName() method in Rule Interface in the following api: http://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/definition/rule/Rule.html

Shekh Akther
  • 713
  • 6
  • 13