Oh my, aren&#39;t we a wee bit too dogmatic? I&#39;ve certainly been known as being a stickler to style and best practice and what not, but in this particular case I&#39;d use a single rule and offload the earth-shaking decision between &#39;Y&#39; and &#39;N&#39; into a function:<br>
<br>rule x<br>when<br>   samplefact1( $status: status, state == &quot;CA&quot; )<br>then<br>   fact0.setField1(  yn( $status)  );<br>end<br><br>Cheers<br>-W<br><br><br><div class="gmail_quote">On 26 January 2012 18:25, Welsh, Armand <span dir="ltr">&lt;<a href="mailto:AWelsh@statestreet.com">AWelsh@statestreet.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You cannot, under normal circumstances, place conditional login in the RHS.  This is by design.  Any conditional logic belongs in the LHS.  If you need to perform conditional logic in the RHS, this is usually an indicator that they rule is not written correctly.<br>

<br>
Now, with that said, there are times when you specifically want to put a decision component in the RHS.  I would do this using a function.<br>
<br>
In your case, it really would make sense to use two rules, to represent your one case, like this:<br>
<br>
<br>
Rule 1<br>
when<br>
                samplefact1( status == &quot;active&quot;, state == &quot;CA&quot; )<br>
<div class="im"><br>
then<br>
                Response fact0= new Response();<br>
                fact0.setField1( &quot;Y&quot; );<br>
                fact0.setName( &quot;something &quot; );<br>
<br>
                insert(fact0 );<br>
end<br>
<br>
</div>Rule 2<br>
when<br>
                samplefact1( status != &quot;active&quot;, state == &quot;CA&quot; )<br>
<div class="im"><br>
then<br>
                Response fact0= new Response();<br>
                fact0.setField1( &quot;N&quot; );<br>
                fact0.setName( &quot;something &quot; );<br>
<br>
                insert(fact0 );<br>
end<br>
<br>
<br>
</div>These two rules are mutually exclusive, only one will fire, and you get the result you want.  It&#39;s really about changing the way you think about decision factors.  You can also achieve the same result like this:<br>

<br>
<br>
Rule 1<br>
when<br>
                samplefact1(state == &quot;CA&quot; )<br>
<div class="im"><br>
then<br>
                Response fact0= new Response();<br>
</div><div class="im">                fact0.setName( &quot;something &quot; );<br>
<br>
                insert(fact0 );<br>
end<br>
<br>
<br>
</div>Rule 2a<br>
when<br>
                samplefact1( status == &quot;active&quot;, state == &quot;CA&quot; )<br>
                $resp : Response ( field1 != &quot;Y&quot;)<br>
<br>
Then<br>
        modify( $resp ) { setField1( &quot;Y&quot; )  };end<br>
<br>
Rule 2b<br>
when<br>
                samplefact1( status != &quot;active&quot;, state == &quot;CA&quot; )<br>
                $resp : Response ( field1 == &quot;Y&quot;)<br>
then<br>
        modify( $resp ) { setField1( &quot;N&quot; )  };<br>
end<br>
<br>
In this scenario, you are changing from hard data mapping to an event oriented rule.  Rule1 creates the basic Response fact, and Rules 2a&amp;2b enrich the response fact based on conditions that may arise throughout the processing of the rules, independent of the initial creation step.  Just whenever you have a response fact that is not Y, set it to Y, and of course the inverse rule...  This requires more processing for the rules, but in a large rules based system this may be more in-line with what  you really want.<br>

<span class="HOEnZb"><font color="#888888"><br>
Armand<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of vadlam<br>

Sent: Thursday, January 26, 2012 8:11 AM<br>
To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
Subject: [rules-users] setting different value in consequence ( RHS part) based on a conditional check<br>
<br>
Hi,<br>
<br>
we have an existing BRL rule in Guvnor whereby we set the value of some<br>
fields in RHS based on some value checks in the condition part. we have<br>
created several of these rules already in a previous release.<br>
<br>
In the next release, we have new requirements to set the value of an<br>
existing field  in consequence to be of 2 different values based on a<br>
specific conditional evaluation. the rest of the rule remains the same.<br>
<br>
to clarify,<br>
<br>
when<br>
                samplefact1( status== &quot;active&quot; , state==&quot;CA&quot; )<br>
<br>
            then<br>
<br>
                Response fact0= new Response();<br>
                fact0.setField1( &quot;Y&quot; );<br>
                fact0.setName( &quot;something &quot; );<br>
<br>
                insert(fact0 );<br>
        end<br>
<br>
we now have to change this to set Field1 value to Y or N based on some<br>
updated condition for status field.<br>
<br>
 lets say if status==&quot;active&quot; , Field1 has to be Y, but when status=closed,<br>
then Field1 has to be N<br>
<br>
Please keep in mind that the rest of the rule remains the same.<br>
<br>
is there a way to set the value of Field1 to be Y or N within the<br>
consequence part of same rule without having to create another rule .<br>
<br>
will the use of functions or variables be of any help in this case?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/setting-different-value-in-consequence-RHS-part-based-on-a-conditional-check-tp3690826p3690826.html" target="_blank">http://drools.46999.n3.nabble.com/setting-different-value-in-consequence-RHS-part-based-on-a-conditional-check-tp3690826p3690826.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>