j-easy / easy-rules

The simple, stupid rules engine for Java
https://github.com/j-easy/easy-rules/wiki
MIT License
4.86k stars 1.05k forks source link

How to add fact in action? #368

Open shabir1 opened 2 years ago

shabir1 commented 2 years ago

In V3 we were able to add fact in action but it is not working in V4. e.g in V3 facts = [{isRaining : true}]

Rule rule1 = new MVELRule() .name("Rule 1") .priority(0) .when("isRaining==true") .then("System.out.println(\"It rains, take an umbrella!\");"weather=\"wet\";umbrella=isRaining""); rules.register(rule1); rulesEngine.fire(rules, facts);

V3 result fact: [{isRaining : true}, {weather : "wet"}, {umbrella : true}]

V4 result fact: [{isRaining : true}] for same input and rule.

chhil commented 2 years ago

See FAQ https://github.com/j-easy/easy-rules/wiki/faqs#8-how-to-addassign-new-facts-in-rules-written-in-an-expression-language