<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.hoenzb
        {mso-style-name:hoenzb;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">As I suggested, if you wish to put conditional logic in the RHS of a rule, you would use a function.&nbsp; I didn&#8217;t provide an example using the function, because
 it did not appear to warrant the need for one, and because I consider this to be a very simplified version of the actual rule.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Again, the decision on how to solve the challenge is up to the developer.&nbsp; Rules engines are not really designed to solve programmer&#8217;s problems, they are designed
 to solve business problems.&nbsp; And the use of functions to apply business logic obfuscates the code, making it less readable by a business analyst, and complicates the development of the code.&nbsp; Placing the decision logic in the LHS keeps the rules simple, and
 thus more maintainable by a business analyst.&nbsp; <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">If only developers will ever look at the code, then I would question the use of drools at all, since many of the challenges we solve with drools can be coded
 more efficiently in straight JAVA code.&nbsp; But again, the decision is always on the developers.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
<b>On Behalf Of </b>Wolfgang Laun<br>
<b>Sent:</b> Thursday, January 26, 2012 10:52 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Oh my, aren't we a wee bit too dogmatic? I've certainly been known as being a stickler to style and best practice and what not, but in this particular case I'd use a single rule and offload the earth-shaking
 decision between 'Y' and 'N' into a function:<br>
<br>
rule x<br>
when<br>
&nbsp;&nbsp; samplefact1( $status: status, state == &quot;CA&quot; )<br>
then<br>
&nbsp;&nbsp; fact0.setField1(&nbsp; yn( $status)&nbsp; );<br>
end<br>
<br>
Cheers<br>
-W<br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal">On 26 January 2012 18:25, Welsh, Armand &lt;<a href="mailto:AWelsh@statestreet.com">AWelsh@statestreet.com</a>&gt; wrote:<o:p></o:p></p>
<p class="MsoNormal">You cannot, under normal circumstances, place conditional login in the RHS. &nbsp;This is by design. &nbsp;Any conditional logic belongs in the LHS. &nbsp;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. &nbsp;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>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1( status == &quot;active&quot;, state == &quot;CA&quot; )<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Response fact0= new Response();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setField1( &quot;Y&quot; );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setName( &quot;something &quot; );<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert(fact0 );<br>
end<o:p></o:p></p>
</div>
<p class="MsoNormal">Rule 2<br>
when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1( status != &quot;active&quot;, state == &quot;CA&quot; )<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Response fact0= new Response();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setField1( &quot;N&quot; );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setName( &quot;something &quot; );<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert(fact0 );<br>
end<br>
<br>
<o:p></o:p></p>
</div>
<p class="MsoNormal">These two rules are mutually exclusive, only one will fire, and you get the result you want. &nbsp;It's really about changing the way you think about decision factors. &nbsp;You can also achieve the same result like this:<br>
<br>
<br>
Rule 1<br>
when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1(state == &quot;CA&quot; )<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Response fact0= new Response();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setName( &quot;something &quot; );<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert(fact0 );<br>
end<br>
<br>
<o:p></o:p></p>
</div>
<p class="MsoNormal">Rule 2a<br>
when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1( status == &quot;active&quot;, state == &quot;CA&quot; )<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$resp : Response ( field1 != &quot;Y&quot;)<br>
<br>
Then<br>
&nbsp; &nbsp; &nbsp; &nbsp;modify( $resp ) { setField1( &quot;Y&quot; ) &nbsp;};end<br>
<br>
Rule 2b<br>
when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1( status != &quot;active&quot;, state == &quot;CA&quot; )<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$resp : Response ( field1 == &quot;Y&quot;)<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;modify( $resp ) { setField1( &quot;N&quot; ) &nbsp;};<br>
end<br>
<br>
In this scenario, you are changing from hard data mapping to an event oriented rule. &nbsp;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. &nbsp;Just whenever you have a response fact that is not Y, set it to Y, and of course the inverse rule... &nbsp;This requires more processing for the rules, but in a large rules based system this may be more in-line with what &nbsp;you really want.<br>
<span style="color:#888888"><br>
<span class="hoenzb">Armand</span></span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><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 &nbsp;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>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;samplefact1( status== &quot;active&quot; , state==&quot;CA&quot; )<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Response fact0= new Response();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setField1( &quot;Y&quot; );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fact0.setName( &quot;something &quot; );<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insert(fact0 );<br>
&nbsp; &nbsp; &nbsp; &nbsp;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>
&nbsp;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><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>