Manish Mulani
Manish Mulani

Reputation: 7375

Get Rule name in "then" clause in drools

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

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

Thanks.

Upvotes: 15

Views: 9638

Answers (2)

Shekh Akther
Shekh Akther

Reputation: 723

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

Upvotes: 4

Cyril Sochor
Cyril Sochor

Reputation: 702

Yes, in then clause you may use expression:

drools.getRule().getName()

Upvotes: 35

Related Questions