Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Conditional Rule Execution #296

Closed Answered by chris-pardy
tapaj asked this question in Q&A
Discussion options

Hi,

I wanted to implementing a chain of three rules, where the second and third rule depends on the result of the first rule. Consider this use case:

Sample Rule Chain

For this, I am creating a new fact using engine.addRuntimeFact("isMinor", <true | false>) and using think fact for the next two rules. The problem is that both softDrinkSelectionRule and AlcoholicBeverageSelectionRule gets executed. I want only one rule to be evaluated on the basis of the outcome of the previous rule.

Is there a better way to implement this?

You must be logged in to vote

If you specify the priority of the rules so that MinorOrNotRule is a higher priority then the other rules an each rule has a high priority isMinor check then while technically both rules will run only the isMinor check would run.
See also #336 for my proposal on how the engine could more easily support this.

Replies: 1 comment

Comment options

If you specify the priority of the rules so that MinorOrNotRule is a higher priority then the other rules an each rule has a high priority isMinor check then while technically both rules will run only the isMinor check would run.
See also #336 for my proposal on how the engine could more easily support this.

You must be logged in to vote
0 replies
Answer selected by chris-pardy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /