0

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 Answers1

0

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
Alex
  • 566
  • 1
  • 6
  • 14
  • I need to to set a generic message through the editor, if property value is changed it shows according to it. Actually, we want customer could also update the message through editor and add message in another language as well. if int A =25, B = 20, C= 30 So my Rule will be like this if if A < B or A> C then set Message to Employee Age could be between B and C So user could see the message like this : Employee age could be between 20 and 30. another message could be like this: Student Age could be greater than B – Muhammad Adnan Khan Oct 08 '20 at 05:06
  • @MuhammadKhan Please refine your question or consider marking my post as "Answered" – Alex Oct 15 '20 at 12:41
  • I want to format the message on editor means, I could bind any field in the string/message through the editor. for e.g if A is lower than B or A is greater than C then set Message="Age must be between B and C" – Muhammad Adnan Khan Oct 18 '20 at 10:09
  • @MuhammadKhan I'm afraid you won't be able to achieve the functionality of the truly dynamic messages with any rule editor that currently exists out there. Rule editors are not IDEs, they are designed for business people. You have to include a certain programming design into your rules in order to have what you want. – Alex Oct 19 '20 at 03:05
  • Thanks, Alex for the clarification – Muhammad Adnan Khan Oct 20 '20 at 09:20