Task 2: Creating a ruleflow

In this task, you create a new ruleflow and modify the existing one.

About this task

Ruleflows chain together tasks, and specify how, when, and under what conditions they are run. Ruleflows are a key component of decision operations, which are used in the deployment of rulesets to production or for testing and simulation. In a deployed ruleset, all the rules of the decision service are included, but only those captured by the ruleflow can be run by the engine.

Step 1: Creating the ruleflow

In this step, you create a ruleflow to sequence more finely the eligibility rules now that the eligibility folder contains a subfolder. The existing ruleflow captures all the rules from its two folders.

Procedure

  1. In the Decision Artifacts tab, and click Miniloan Service to display the artifacts.
  2. In the display area, click the Create an artifact button "", and select New Ruleflow.
  3. Enter eligibilityflow as the name of the new ruleflow, and then click Create.
    The ruleflow editor opens with the starting point for a ruleflow, that is, a start node, a transition link with no condition, and an end node:
    Image shows the ruleflow with start and end tasks.
  4. Hover over the transition link between the start and end nodes, and then click the "" button.
    A menu containing different types of tasks is displayed:
    Image shows the menu of task nodes.

    A rule task contains a set of rules to be run at that point in the ruleflow. An action task contains rule statements to be run. A subflow task references another ruleflow. You sees subflow tasks in the next step.

  5. Click Rule Task.
  6. Click the new rule task in the ruleflow. Enter eligibilitytask in the Label field, and then copy the following description into the Documentation field:
    Runs all and only the eligibility rules
  7. Click Edit beside the Uses field.
  8. In the Rule Selection Editor, select the eligibility folder, and then click Add.
    The folder is added to the rule task. Any rule that you subsequently add to this folder is part of the ruleset when you deploy, and can be run by the engine.
  9. Although duration is a subfolder, you must add it explicitly to the rule task. Select the duration folder, and then click Add.
    Your rule selection looks as follows:
    Image shows the rule selection editor.
  10. Click OK, and then close the dialog box.
    The ruleflow runs all the rules from the eligibility and duration folders. You see in the next task the different possibilities for defining the sequence in which the rules contained in a rule task can be run.
  11. Click the End node, and then click the Edit button.
  12. In the editor, copy the following instruction, and click OK:
    print "Eligibility rules have been evaluated : result is : " + the approval status of 'the loan' ;

    This instruction on the end node gives you some visibility on the running of the ruleflow. Placing the instruction in an action task after the rule task would have the same effect.

  13. Click the Arrange button "" to get an optimized layout.
  14. Click Save, and then click Create New Version.

Step 2: Adjusting the existing ruleflow

In this step, you adjust the miniloan ruleflow to replace its eligibility task with a call to eligibilityflow as a subflow. Creating a subflow task is more convenient because you do not have to modify miniloan every time you adjust eligibilityflow.

Procedure

  1. Click the miniloan ruleflow, and in the display area, click the edit button.
  2. Click the data approved transition link between the validation and eligibility tasks, anywhere except on the "" button.
    You see the following condition on the transition between the two tasks:
    'the loan' is approved 

    The ruleflow moves to the other task only under this condition. Otherwise it moves to the end node.

  3. Close the pop-up. Hover over the data approved link, click the "" button, and then click Subflow Task.
  4. Hover over the subflow task, click and hold the "" button at the bottom of the task, and drop it onto the end node.
    At this point, your ruleflow should look like the following:
    Note: The subflow task is in error because it has no content yet.
    Image shows the rule selection editor.
  5. Delete the eligibility task by clicking it and pressing the Delete or Backspace button on your keyboard.
  6. Click the Arrange button "" to get a better layout.
  7. Click the subflow task and change the label to Eligibility subflow.
  8. In the Subflow field, select eligibilityflow.
    Close the pop-up. Your ruleflow now looks as follows:
    Image shows the ruleflow.
  9. Click Save, and then click Create New Version.

What to do next

In the next task, you explore the sequencing possibilities within a rule task.