RuleAPI:Procedural commands

From FlexRule Wiki
(Redirected from Procedural commands)
Jump to: navigation, search

Commands in procedural rules may fall into different categories. They will be available in Procedural logic that your application can create an instance of and execute the rules. These commands are suitable for implementing low level functionality, algorithms implementation, complex logic validation, communication to external resources, object creation and variable value manipulation, object and class level method invocation, accomplishing repetitive tasks, implementing modular rules and logic, database access and so on. Also, it is possible to extend the commands in this Procedural logic and define your required behavior.

Procedural Commands

Declaration and Assignment commands

This group of commands are responsible for declaring and defining the rule structure and available commands on the rule.


This command defines a procedure that is executable in the procedural logic. The entire rule logic must be placed inside this command. A procedure is a low level functionality or behaviour that can handle complex rules or logic. It is also a reusable part of flow logic. It may have calculations, conditions, assignments, etc. A procedure is an executable routine of a rule or logic. It may have input, output or local parameters from different CLR types. In order for a procedure to execute different commands it must include a Handlers command. Handlers define what commands are available inside a procedure. Procedures can be divided into different sections named Scope. Each Scope will also be able to accept some parameters.

View signature


This is the section that contains all of the command handlers. This section of a rule will be loaded automatically and is responsible for registering all of the other handlers of the rule. Each command in the rule must be introduced by a handler.

View signature


A handler is a factory that provides all the command execution and definition mechanisms in the rule. This is the command extension points of the procedural logic. If you want to conduct any specific task for which we do not provide a command at the procedural rule level then you need to create a handler and register it using this command. All out-of-the-box commands also follow the same pattern to be registered in the rule logic and allow the rules to behave in a defined way using a particular command (e.g., If | While | Database, etc.).

View signature


Each rule has a specific signature that defines all of the rule parameters. These rule parameters can be defined in different modes: Input, Output, and Local. And their parameters can be in any internal or custom CLR types. That allows the calling application to be able to send any type of value to rules for processing and then retrieve any types of result from the engine when the processing is finished or even during the execution. Also Usings can be defined in this section of rule.

View signature


This command defines the rule parameters. It can be in different directions: Input, Output and local. There is no limitation on the numbers or types of the defining parameters. It can either have none or as many parameters as required. The input parameters must be passed through with the executing applications.

View signature


If there is a type whose static members are required during the evaluation, it has to be registered by this command

View signature


This command will manage a defined parameter's value. It can access the value and manipulate it. The value can be in any type and the command is able to read and write the value or a properties of a value.

View signature

Flow Control commands

This group of commands is responsible for managing the execution flow inside the running rule.


This command creates a loop and all the child commands inside it get executed until you ask it to exit the loop by using ExitDo. The 'do' statement executes a statement or a block of statements repeatedly.

View signature


While this is similar to Do, this involves entering a condition which will be evaluated in every iteration of the loop. The engine will exit the execution of loop when the condition is evaluated as a false value or it reaches the ExitWhile command.

View signature


This command can be used when iterating a collection or list. The engine exits the iteration when it reaches the end of the collection or ExitIterate command.

View signature


When a direct evaluation of a condition is required inside a rule, this command can be utilized. For more complex logic ElseIf and Else can be used to complete the decision.

View signature


This command will handle any exception occurring inside its execution block. If any exception occurs during the execution, it will go to its Catch block.

View signature


When an exception occurs, the execution path will come to this block. Then it is time for processing what has gone wrong.

View signature


For any conditions for which you may want to halt the rule execution. In this case, this command can throw an exception and halt the rule execution. Your calling application will then receive a signal because of the thrown exception.

View signature


When you need to group similar logic inside a rule so that you avoid duplicating these all over your code, this command will be useful. The other parts of the rule can then Call to a specific named scope and pass some input parameters and retrieve some results. Also scope can be a reusable module between different procedural rules.

View signature

Object Creation commands

When dynamic creation of objects is required, this set of commands can be used.


If instantiation of a type is required in the rule execution, this command can be used. It allows the creation of objects from any type using their constructors.

View signature


This command is a type constructor selector. It selects a suitable constructor of a type to be used to instantiate an object.

View signature


Creating an array of objects is possible using New command. However it might be easier to use this command instead to populate the values of the array directly.

View signature


This command will be used inside the Array command and will add values for each index of the array.

View signature


This command creates a list that can act as a collection or set.

View signature


This command allows the building of a template to generate a table of data based on a set of inputs.

View signature

Task Commands


Calls out to any REST API and returns the results.

View signature


When there are objects defined inside a rule, this command can make a call to the object methods.

View signature


Calling a function and method by passing input parameters as embedded elements rather than attribute values.

View signature


If your application logic is complex and requires multiple Procedural rules, this command can call an externally defined rule and return the result to the running execution context.

View signature


When your rule has some scopes this command can call to and execute the scope, and then return to its previous execution path.

View signature


Sometimes the calling application requires signals to be received from the executing rules. This command will send an event to the running engine and then your application, and handle the event required to respond to the rule signal.

View signature


When scopes are defined on a separate physical layer (different files than the actual rule), this command will load the external scope inside the current loaded rule.

View signature


For lots of commands, some initialization values are required. This command is responsible for preparing and passing the values to the Rule commands.

View signature

Database commands

This set of commands enables the rule to communicate with a data source (database) and retrieve a value, single row or multiple rows as part of the rule execution process.


This command defines a connection to a data source: MsAccess, MsSql, Oracle, ODBC.

View signature


When rows are required to be retrieved from a database table, this command can be used.

View signature


When rows are required to be retrieved from a database table this command can be used to create a list of values, either simple primitive values or complex object values.

View signature


When a single value (cell value) is required to be selected from a database table, this command can be used.

View signature


When the Insert, Delete or Update command is required, this command can be used.

View signature


If the result of executing a query returns a value, this command should be used.

View signature