Show TOC

Background documentationDynamic Expression

 

The dynamic expression is used to call another expression dynamically. The called expression is not statically defined at runtime. Rather, it is dynamically determined at runtime based on the evaluation result of a nested expression that is assigned to the dynamic expression at design time. This can be useful if you have a set of specialized expressions that are optimized to handle specific use cases that are different in certain details but similar in nature. With the help of the dynamic expression, it is possible to determine the most suitable expression at runtime.

Features

Context Mapping

The dynamic expression offers the following modes for the context mapping:

  • Complete context but not expression variable

    All available context data objects of the dynamic expression are supplied to the called expression.

  • Matching context

    Only those context data objects of the dynamic expression that can be matched to the context data objects of the called expression are supplied to the called expression.

Called Expression

You choose one expression and assign it to the dynamic expression. The assigned expression is called by the dynamic expression at runtime. The called expression must be configured such that it handles the context data provided by the dynamic expression, and returns a text data object as result. The result must contain the ID of a particular expression to be processed, depending on the context data. The result of this secondary expression is then passed back to the dynamic expression.

Result Data Object

For the result data object, you can use any kind of data object. However, it is important to make sure that the result data object of the dynamic expression and the result data objects of all the secondary expressions must be compatible.

Constraints

Unlike most other object types in BRFplus, there is no code generation support for dynamic expressions. Therefore, this expression type is not recommended for time-critical tasks, or scenarios where high data load is expected.

Example

In a rule system for a social services authority, you want to handle application forms for different types of services such that they can be entered into the system with the help of an expression serving as a single point of entry for the business user. Then, you use a dynamic expression to determine the type of the application form to be processed. In the dynamic expression, you use a decision table as nested expression. By passing the application form type information to the decision table as context data, the decision table determines the expression associated to the application form type in question and hands the form over to that expression for further processing.