0

I have 250 Execution rules. Today, I evaluate them 1 at a time in a loop in order. The first one that evaluates true stops the loop. I save off the result and which rule was used.

I would like to use a ruleset for performance reasons. Is there a way to know which rule (or rules depending on behavior) evaluated true? Maybe an array of the ruleids?

itsallyours
  • 168
  • 7

1 Answers1

0

Declare a "state" field in your source class and set its value to the rule evaluation result for each rule in your ruleset. Check the value of that field after the evaluation of your ruleset is finished to determine which rule(s) has evaluated to true:

[ExcludeFromEvaluation]
public string Output;

[Action("Output")]
public void SetOutput(string val)
{
   this.Output += val;
}

The rule example:

If Something is True then Output ( "Something was true" ) and Do Something Amazing
Alex
  • 566
  • 1
  • 6
  • 14
  • I did think about this as a solution. However, I don't think I can rely on the end users to add this as an action. I might be able to dynamically add it the XML. If I did that, is there a way to "hide" that method from the editor but still be able to use it during runtime? – itsallyours Jul 07 '21 at 23:49
  • No, there is no "normal" way of hiding a field or method that exists in the Rule XML from the user/editor. You need to remove that node from the Rule XML before loading it into the editor. – Alex Jul 09 '21 at 11:41