Try reading the Drools Expert User Guide section about the use of Globals :)<br><br>Globals are not Facts to be reason in the Left-Hand-Side (WHEN) part of a rule.<br><br>Either use the Global (assuming it contains static data) and initialize it correctly from within Java code (see the User Guide) or insert it as a Fact and reason with it.<br>
<br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">On 26 July 2012 09:38, zeeshan <span dir="ltr">&lt;<a href="mailto:zeeshan.spring@gmail.com" target="_blank">zeeshan.spring@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All !<br>
<br>
I am trying use global variable in DRL file but when I am using it, gives<br>
Exception. Please have a look at the DRL file -----<br>
<br>
<br>
<br>
<br>
package com.drools.rules<br>
import com.drools.facts.*;<br>
*global CSVBeanAgent csvAgent;*  [here I have declared the Global variable]<br>
<br>
<br>
<br>
rule &quot;Calculating Agent APE&quot;<br>
<br>
        salience 35<br>
        no-loop true<br>
        when<br>
<br>
                $csvPolicy : CSVBeanPolicy()<br>
                //$csvAgent : CSVBeanAgent()<br>
        then<br>
<br>
<br>
   System.out.println(&quot;For agent ---&gt;zzzzz in rule setting premium form<br>
rate&gt;&gt;&gt;&gt;&quot;+$csvPolicy.getPremiumMode());<br>
    double policyAPE=$csvPolicy.getPolicyAPE();<br>
    System.out.println(&quot;policyAPE&gt;&gt;&gt;&gt;&gt;&quot;+policyAPE);<br>
    *System.out.println(&quot;Agent<br>
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz&gt;&gt;&gt;&gt;&gt;&quot;+csvAgent);*<br>
    double agentAPE=0.0;<br>
      if(csvAgent.getAgentNo()==$csvPolicy.getAgentNo()){<br>
      System.out.println(&quot;inside if&quot;);<br>
     agentAPE=agentAPE+policyAPE;<br>
      }<br>
      csvAgent.setAgentAPE(agentAPE);<br>
           System.out.println(&quot;AgentAPE&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&quot;+csvAgent.getAgentAPE());<br>
           update($csvPolicy);<br>
<br>
end<br>
<br>
<br>
Above is my rule....the Bold one is I am trying to the value of *csvAgent*,<br>
it gives *null* value. Please help me in finding the solution i.e. How to<br>
declare the global variable and how to use it in DRL file.<br>
<br>
Thanks !<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp4018911.html" target="_blank">http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp4018911.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>
</blockquote></div><br>