◷ Reading Time: 6 minutes


Notification is a way of collecting some feedback from the engine while it is running. There might be different reasons for collecting feedback:

  • Visibility to execution
  • Log, trace…
  • Checking some results
  • Sending feedback to host

and so on…

A notification can be accessed via Notification commands in all types of logic documents (e.g., flow, procedural, workflow, etc.). However, in a validation document, direct access is not possible, but you can use the message setting of Validation commands to record the result inside the notification.


Notice is a message that will be placed into a notification group. By default if the group is not defined, it will be stored in a defaultgroup.


Notifications can be grouped by a name. Grouping allows you to organize notices in different Notifications. Then each group of notices (Notification) may serve a particular purpose in your specific scenario. For example, you can separate UI response notices from Audit messages by putting them in different Notifications.

Cross-logic document notification

In an execution, Notification will be shared across all of the logic documents. The rule that has initiative would push its Notifications tray to all of the underlying rules. For example, if you have a Flow that has a Validation and a Procedure, then NotificationSet from the parent (Flow) will be shared with those Validation and Procedural rules, and in turn they can create and maintain their own Notifications.

This behavior allows your application to collect all the notices related to its execution.

Formatting messages

Notices in the notification can be formatted as required. You can put placeholders to be filled by the values of the context as they are available. To define a placeholder you can put an expression between { and } and the value from context will replace those placeholders.

<Notice message="your age {person.Age} is less than 18" type="error"/>

Accessing Notification

In your code, once you execute your rule, you can collect notifications from your execution context or Runtime Result.

For example, consider following Validation logic:

<Validation name="product check">
    <Define name="product" direction="in"/>
    <Define name="total" direction="local"/>
    <Define name="validPoint" direction="local"/>
  <Logic name="main">
      <Null negate="true" value="product" message="product not exists"/>
      <Var name="total" value="product.Quantity * product.Point"/>
      <And processAll="true">
        <Var name="validPoint" value="total>=20"/>
        <Check value="validPoint" message="un-authorized"/>
        <Check value="!validPoint" message="authorized" noticeFor="success" notice="information"/>

Then the logic is executed, you can collect the notifications like the code below:

public void expect_unauthorized_when_point_lessOrEqual_than_20()
    var product = new Product() { };
    var content = File.ReadAllBytes("product_access.xml");
    var engine = RuntimeEngine.FromXml(content);
    var res = engine.Run(product);
    // Retrieve list of notification from the result
    var list = res.Notifications.Default.Notices.Where(x => x.Type == NoticeType.Error).ToList();
    Assert.AreEqual(1, list.Count);
    Assert.AreEqual("un-authorized", list.First().Message);

Notification API

You can define Notifications across your logic.

Notification in a Decision Table

In any Decision Table, you can write notices as part of the success or failure to meet conditions. Because of the way Decision Tables work, its API for notifications are different from other types of logic (e.g., validation, flow, procedural, etc.).

Notification in Decision Tables works based on an action column with a Notice type. What you need to do is to set the type of action to Notice. If you need to define the type of notice you can set notice attribute values. The template of the message comes from the data cells. 


Scenario: If there is a duplicate in a list of people, write an error notification. The decision table shown below writes the notification using a message template:

In your FlexRule Designer, the properties of the action column named Write Error Message is:

Here is an example of the table definition:

<DecisionTable name="Identify duplicates in list">
    <Define name="persons" direction="In" />
    <Define name="duplicates" direction="Local" />
    <Condition name="Has Duplication" expression="duplicates.Count gt 0" />
    <Action name="Write Error Message" expression="$value" type="Notice" onArray="duplicates" elementName="$x" />
    <Action name="Create Duplicate List" expression="duplicates = $value |groupBy(p, p.Name) |where (g, g.Count>1) |select(d, d.Key)" />
    <Name />
      <Value>: persons</Value>
      <Value>Building Duplicates</Value>
      <Value>Person named '{$x}' is duplicated in list.</Value>
      <Value>Duplicate Check</Value>

If you need multiple notices in your notification, then simply add multiple actions and you can set a notice property for generating an error, warning or information type of message.

Please note, because we want to apply this action to all elements of the collection named people, we set the onArray and elementName of the action.


There are also some functions dealing with notifications, if you need them at the expression level.

For more details visit Notification functions.

Notification in a Natural Language Document

In this Natural language implementation, Notifications are used as function level. The following document has two different logics to pass the notification message to execute the notification function. (Add Error Reason() , Add Error Reason() With Registration Number ())

Different NL functions

Then those two logic implementation will be as follows to call the Notification Function.

Notification in NL

Updated on October 30, 2023

Was this article helpful?

Related Articles