[rules-users] how to find the rule name

Marina ppine7 at yahoo.com
Wed Jul 2 17:09:05 EDT 2008


Hello,

I need to know the rule name of the rule that fired in the consequence part of the rule. I tried something like the following, just trying to see if I can get it this way:

package mode.simple;
import java.lang.String;
import java.util.List;
import com.emptoris.ecm.domain.ContractRulesData;

global java.util.Set approverList;

rule "testOR_1"
    dialect "java"
    when
        $data : ContractRulesData (sum > 500 || name matches ".*important")
    then
        approverList.add("approver3, approver4, Level5");
        ruleName = drools.getRule().getName();
        System.out.println(ruleName + " is TRUE");

end

When I'm trying to compile the rule, I'm getting the following error:
Builder errors: 
Rule Compilation error : [Rule name=testOR_1, agendaGroup=MAIN, salience=0, no-loop=false]
    mode/simple/Rule_testOR_1_0.java (8:391) : ruleName cannot be resolved
    mode/simple/Rule_testOR_1_0.java (9:452) : ruleName cannot be resolved
java.lang.RuntimeException: Unable to compile rules file: testOR_1.drl

I must be doing something wrong here... ?

thanks!
Marina



More information about the rules-users mailing list