Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Rule Entry information within GRL "then" clause #390

Open
ngmarcus opened this issue Aug 1, 2023 · 0 comments
Open

Expose Rule Entry information within GRL "then" clause #390

ngmarcus opened this issue Aug 1, 2023 · 0 comments

Comments

@ngmarcus
Copy link

ngmarcus commented Aug 1, 2023

Note: If such a feature already exists, appreciate if anyone can help provide usage information.

Is your feature request related to a problem? Please describe.
As a client, I want to be able to identify which rule entry within the knowledge base had its "then" condition triggered.

For example, if I want to attach a message indicating which rules were executed, currently I would need to hard-code the rule name manually.

Current way:

rule test_rule_name "test_rule_description" salience 1 {
    when
		1 == 1
    then
		Test.DoSomething("test_rule_name"); // repeated rule name here
}

Ideally, I can simply call a method that returns the rule name. For example:

rule test_rule_name "test_rule_description" salience 1 {
    when
		1 == 1
    then
		Test.DoSomething(RuleEntry.GetRuleName()); // if rule name changes, this part doesn't need to change
}

Describe the solution you'd like
A default, reserved parameter inside DataContext named "RuleEntry" that contains the rule entry struct itself (or a similar struct that provides relevant data via getter methods, to prevent modification on the rule entry itself). This should be initialised each time we start a new rule execution.

Describe alternatives you've considered
This is more of an improvement to allow better rule definition design that is in-line with DRY principle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant