views:

321

answers:

2

How do I set a global in Drools 4 from within a rule? I want to set a boolean if a rule fires so that it can read it from another rule with a lower salience.

A: 

Assuming you're using Drools 5.x, you can do this in your rule consequence:

kcontext.getKnowledgeRuntime().setGlobal(name, value);

Kris Verlaenen
Sorry I forgot to mention it is Drools 4
Tarski
A: 

You might be able to do something like:

drools.getWorkingMemory().setGlobal... (similar to above, what kris said).

Michael Neale