Business Rules Activity Module

This chapter covers the appRules Business Rules activities.  We will review the the appRules Business Rules module to deliver a very powerful and flexible business rules environment. 

 

The If activity can be nested in an unlimited number of ways to model business rules.  See the example below.

 

image062.jpg 

 


 

 

The WhileActivity activity iteratively executes a single child activity as long as its Condition property is true. A rule condition that is associated with the Condition property is evaluated before each iteration of the WhileActivity loop. If the condition evaluates to true, the child activity is executed. If the condition evaluates to false, the child activity is not executed, and the WhileActivity activity finishes.   

 

image063.jpg 

 

  image064.jpg 

 

The appRules Business Rules module is made up of six powerful workflow activities.  The module is automatically selected in the toolbox.  It includes activities for performing actions, evaluating conditions, evaluating decision tables and for executing rule sets.

 


 

 

 

The following activities are used for performing actions:

 

Action

Perform Actions

Action Activity

 

The Action activity is used to perform any action available in appRules.  To configure an Action activity, drag the Action activity on to the designer.  The Action Configurator window will be displayed:

 

image065.jpg 


 

 

To configure the action,

  • Select the action category (e.g. Dynamics365)
  • Click on the category to display a list of the available action types (e.g. Dynamics365 action types shown below:

 

image066.jpg 

  • Double-click on the action type (e.g. InitializeSource) and the configuration window for the action will be displayed:

 

image067.jpg 

Configure the Action and click on the OK (first) button to accept the changes.  For additional information regarding specific actions, refer to the Connector Reference manual.

 

Perform Actions Activity

 

The PerformActions activity is used to perform a group of actions.  To configure the PerformActions activity, drag the PerformActions activity on to the designer.  The following window will be displayed:

 

image068.jpg 

To add Actions to the list of actions to be performed:

·       Click on the button next to the Action Description column to display the Action Configuration window. 

 


·       image071.jpg

 

  • Configure the Action as explained in the section above (Action Activity).
  • Select the option for executing the Actions from the Option list.
  • Right-Mouse-Click on the window to view a menu of additional options :

 


 

 

The following activities are used for evaluating conditions:

 

Condition

Evaluate Conditions

Condition Activity

 

The Condition activity is used to evaluate a condition in appRules.  To configure a Condition activity, drag the Condition activity on to the designer.  The Condition Configurator window will be displayed:

 

image073.jpg 

 

 

 

To configure the condition,

  • Click on the ConditionSettings collection button

 

image074.jpg 

 

 

  • Click on the category to display a list of the available condition types (e.g. DynamicsCRM condition types shown below:

 

 

  • Double-click on the action type (e.g. IsOptionSetValueValid) and the configuration window for the action will be displayed:

 

Configure the Condition and click on the OK (first) button to accept the changes.  For additional information regarding specific actions, refer to the Connector Reference manual.

 


 

 

Evaluate Conditions Activity

 

The EvaluateConditions activity is used to evaluate a group of conditions.  To configure the EvaluateConditions activity, drag the EvaluateConditions activity on to the designer.  The following window will be displayed:

 

image077.jpg 

To add Conditions to the list of conditions to be evaluated:

 

  • Click on the ConditionItems collection to display the Conditions List

 

image078.jpg·       Type a description each Condition and click on the button in the middle of the line to access the Configuration window. 

  • Configure the Condition as explained in the section above (Condition Activity).
  • For each Condition specified you can specify action(s) if condition evaluates to true or false


 

 

  • Right-Mouse-Click on the window to view a menu of additional options (related on the current line clicked):

·        

image079.jpg
 

 

  • In the first window, you can select the iterationoption :

 

image080.jpg 


 

 

 

 

The EvaluateDecisionTable activity is used for defining, validating and executing decision tables.  Instead of going into a detailed discussion of the history of decision tables and the benefits, we will use the “CustomerDiscount” project in the Samples database to help you “hit the ground” running with decision tables in appRules.

 

The “CustomerDiscount” decision table applies the appropriate discount to a customer order based on predefined conditions as shown in the table below:

 

image081.jpg 

 

In this example, there are four conditions (the rule), to be used for deciding the discount to be applied to a customer order:

 

1.   New Customer: Whether the customer is a new customer

2.   Product Category: The category of the product being ordered

3.   Sale Amount: The amount of the order

4.   Number Of Prior Orders:      The number of prior orders received from the customer

 

 

If the result of executing every condition on the row is “True”, then the following actions will be performed:

       

1.   Discount Percent:       The discount percent to be applied to the order

2.   Free Shipping:            Whether to offer free shipping to the customer

 

 

 

 

 


 

The Decision Table Context Menu

 

 

To access the context menu for the decision table, right-click on the table.  The menu items displayed will depend on the state of the table.   

 

 

The context menu below is displayed when Conditions and Actions have not been defined:

 

image082.jpg 

 

 

The context menu below is displayed when Conditions and Actions have been defined:

 

 


 

 

 

 

Creating Decision Tables

 

To create a new Decision Table, drag the EvaluateDecisionTable activity on to the designer.   The Decision Table Editor window will be displayed:

 

image084.jpg 

Right-click on the table to define the Conditions and Actions.  Right-click displays a context menu of the available options for the row, column, or the decision table in general.

 


 

Adding a New Condition

 

To add a new condition to the decision table, select “Add New Condition” from the context menu.  The Add Condition Items Settings window will be displayed. 

 

 

 

 

Enter a name for the Condition in the ConditionItemsName property.   You can define each condition entry individually by clicking on the ConditionItems property, or you can click on the ConditionSettings property to create the entries as a group.   


 

Adding a New Action

 

To add a new Action to the decision table, select “Add New Action” from the context menu.  The Add Action Items Settings window will be displayed. 

 

image086.jpg 

 

Enter a name for the Action in the ActionItemsName property.   You can define each action entry individually by clicking on the ActionItems property, or you can click on the ActionSettings property to create the entries as a group.

 

 

Adding Decision Rows

 

To add new decision rows to the decision table, select “Add New Rows” from the decision table context menu.  The following window will be displayed:

 

 

Enter the number of rows to add and select the default row values.

 

Testing Decision Tables

 

image088.jpg 

To test your decision table, simply click the Run button from your IDE.  If the ViewExecutionResults property is set to True (checked), the result of the run in debug mode will be displayed as shown next page:

 

 

 

image089.jpg
 

 

 

The ExecuteRuleSet activity is used for defining, validating and executing Rule Sets in appRules.  Rule Set in appRules is a set of rules and the Actions to be performed when each rule evaluates to true or false.

 

Creating Rule Sets

 

To create a Rule Set, drag an ExecuteRuleSet activity on to the designer.  The following screen will be displayed:

 

image090.jpg 

Click the Rules property to enter the rules and the actions to be performed for each rule (see next page)

 

image091.jpg 

Enter a Rule Name, then click on the button after the name to set the related condition.

For each rule, you can set action(s) if true or false.

 

To add new rules and actions, right click in the related area of the window to display the context menu:

 

 


 

Testing Rule Sets

 

To test your rule set, simply click the Run button from your IDE.  If the ViewExecutionResults property is set to True (checked), the result of the run in debug mode will be displayed.