easy-rules icon indicating copy to clipboard operation
easy-rules copied to clipboard

How to update facts in Action:

Open sss534534 opened this issue 4 years ago • 2 comments

how to update facts in yml:

`name: "weather rule" description: "if it rains then take an umbrella" condition: "rain == true" actions:

  • "System.out.println("It rains, take an umbrella!");"
  • "facts.put("umbrella", true); "`

[Error: unresolvable property or identifier: facts] [Near : {... facts.put("umbrella", true); ....}] ^ [Line: 1, Column: 1]

sss534534 avatar Nov 22 '21 07:11 sss534534

Just Same meaning as below:

``

    org.jeasy.rules.api.Rule weatherRule = new RuleBuilder()
            .name("weather rule")
            .description("if it rains then take an umbrella")
            .when(facts -> facts.get("rain").equals(true))
            .then(facts -> {
                System.out.println("It rains, take an umbrella!");
                facts.put("umbrella", true);
            })

``

sss534534 avatar Nov 22 '21 10:11 sss534534

See FAQ

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

chhil avatar Dec 02 '21 10:12 chhil