<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Thanks, Steven, Scott,<br>yes, that worked. The reason I did not do it in the first place is because I was looking for examples of variable declaration in RHS and the only one I found was the PetStore.drl:<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println( "Adding free Fish Food Sample to cart" );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; purchase = new Purchase($order, $fishFoodSample);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; insert( purchase );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $order.addItem( purchase );&nbsp;&nbsp;&nbsp; <br><br>Since the 'purchase' object was not declared using Java syntax I assumed that is the Drools syntax... Maybe it's a typo in the example? I did
 not run it myself.<br><br>Anyway, it works now :-)<br><br>Thanks!<br>Marina<br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Scott Burrows &lt;scottjburrows@gmail.com&gt;<br>To: Rules Users List &lt;rules-users@lists.jboss.org&gt;<br>Sent: Thursday, July 3, 2008 8:10:35 AM<br>Subject: Re: [rules-users] how to find the rule name<br><br>
The RHS of the rule uses Java syntax, so you need to declare all vars.&nbsp; You need to declare "rulename" as a String.<br><br clear="all">Scott Burrows<br>407-739-7752
<br><br><div class="gmail_quote">On Wed, Jul 2, 2008 at 5:09 PM, Marina &lt;<a rel="nofollow" ymailto="mailto:ppine7@yahoo.com" target="_blank" href="mailto:ppine7@yahoo.com">ppine7@yahoo.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
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:<br>
<br>
package mode.simple;<br>
import java.lang.String;<br>
import java.util.List;<br>
import com.emptoris.ecm.domain.ContractRulesData;<br>
<br>
global java.util.Set approverList;<br>
<br>
rule "testOR_1"<br>
 &nbsp; &nbsp;dialect "java"<br>
 &nbsp; &nbsp;when<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$data : ContractRulesData (sum &gt; 500 || name matches ".*important")<br>
 &nbsp; &nbsp;then<br>
 &nbsp; &nbsp; &nbsp; &nbsp;approverList.add("approver3, approver4, Level5");<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ruleName = drools.getRule().getName();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;System.out.println(ruleName + " is TRUE");<br>
<br>
end<br>
<br>
When I'm trying to compile the rule, I'm getting the following error:<br>
Builder errors:<br>
Rule Compilation error : [Rule name=testOR_1, agendaGroup=MAIN, salience=0, no-loop=false]<br>
 &nbsp; &nbsp;mode/simple/Rule_testOR_1_0.java (8:391) : ruleName cannot be resolved<br>
 &nbsp; &nbsp;mode/simple/Rule_testOR_1_0.java (9:452) : ruleName cannot be resolved<br>
java.lang.RuntimeException: Unable to compile rules file: testOR_1.drl<br>
<br>
I must be doing something wrong here... ?<br>
<br>
thanks!<br>
<font color="#888888">Marina<br>
_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>
</div></div></div></body></html>