To set a global called "prodName" to the value returned by getName() within a rule's consequence you should use
   drools.getWorkingMemory().setGlobal( "prodName",  getName() );
-W

On 4 November 2010 18:15, rajivharris <rajivharris@gmail.com> wrote:

Hi,
I am setting a String variable as global. And trying the access the same in
my Java program. Can anyone help on how to do this.

code snippet:
global String prodName;

rule "Your First Rule"

       when
               #conditions
               eval (true)
       then
               #actions
               prodName= getName();
               System.out.println( "name:" +prodName);

end

Thanks,
Rajiv.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/accessing-a-drools-variable-tp1843203p1843203.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users