How could I set a dynamic message through Rule editor?

135 Views Asked by At

I need to set a dynamic message based on the parameter fields value in the rule editor. for e.g If A < B or A > C then set Message to A value should be in between C and D

1

There are 1 best solutions below

5
On

UPDATED:

Having a source object like this:

public class Source
{
   private const string template1 = "Age must be between {0} and {1}";
   private const string template2 = "Student Age could be greater than {0}";

   public int A, B, C;

   public bool InvalidAge, StudentAge;

   [ExcludeFromEvaluation]
   public string MessageToEmployee;

   public void Display()
   {
      if(InvalidAge)
         this.MessageToEmployee =
            string.Format(this.template1, this.B, this.C);
      else if
         this.MessageToEmployee =
            string.Format(this.template2, this.B);
      else
         this.MessageToEmployee = "The validation has passed successfully";
   }
}

... you can create your rule like this:

If
   A is lower than B or
   A is greater than C
      then
         set InvalidAge to True and
         Display
Else If
   A is lower than B
      then
         set StudentAge to True and
         Display
Else
   Display