[rules-users] or condition - subrules

Scott Reed sreed at avacoda.com
Fri Jan 16 11:59:22 EST 2009


I think it would be like this:

rule "Test"       
        when       
                $ca: CoApplicant()
                $co: Contract()
                eval ( $c1.getRelationship().equals("S") ||
                         $co.getState().equals("CO") ||
                         $co.getState().equals("IL") ))
        then
        ...
I am no expert but you also might be able to achieve what you want a 
little more efficiently with a global that ensures the consequence only 
executes once:

global boolean flag = true;
rule "Test"       
        when       
                (CoApplicant( relationship == "S" ) or (Contract ( state 
in ("CO", "IL"))))
                eval( flag )
        then
               flag = false;
        ...

kfs2 at chryslerfinancial.com [1/16/2009 11:35 AM] wrote:
>
> I understand that as this rule is written below it will be compiled 
> into 2 subrules which both fire.  I searched the archives and found a 
> post where Mark Proctor suggested "Bind each pattern, and do the || 
> field constraints in an eval.". I'm new to Drools, can someone 
> elaborate on how I would do that with the rule below?
>
> rule "Test"        
>         when        
>                 (CoApplicant( relationship == "S" ) or (Contract ( 
> state in ("CO", "IL"))))
>         then
>         ...
>
> Thanks
>
> Kent    
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090116/e1c3fa0c/attachment.html 


More information about the rules-users mailing list