< Previous | Next >

Task 7: Writing action rules

You add several action rules to a decision table, and define the rules with the Business Action Language (BAL).

About this task

In this task, you write five action rules and put them into the relevant packages. You can write rules in Rule Designer or in Decision Center. If you work in Decision Center, synchronize the decision service with Rule Designer before you begin.

You create the following rules in the eligibility and validation packages.:
Package name Rule name
eligibility

MinimumNetIncome

validation

MaximumAgeReq

MaximumAmount

Important: You might have to verbalize the Borrower and Loan classes to match the locale of your rule editor.

Procedure

  1. Create the MinimumNetIncome rule:
    1. In the rule project, right-click the eligibility package and then click New > Action Rule.
    2. In the Name field, type MinimumNetIncome.
    3. Click Finish.

      The Rule Explorer view displays the new action rule and the Intellirule editor opens. You can switch to the guided editor if you prefer.

  2. Write the MinimumNetIncome rule as follows:
    if
       the income after tax of 'the borrower' is less than 24000 
    then
       add "The yearly income is lower than the basic request" 
       to the messages of 'the loan' ;
       reject 'the loan' ;
  3. In the validation package, add the following rules:
    Name Rule
    MaximumAgeReq
    if
        the age of 'the borrower' is more than 65 
    then
        add "The age exceeds the maximum." to the messages of 'the loan' ;
        reject 'the loan' ;
    MaximumAmount
    if
      the amount of 'the loan' is more than 1000000
    then
      add "The loan cannot exceed 1000000" to the messages of 'the loan' ;
      reject 'the loan';
  4. Right-click the eligibility package and then click New > Decision Table.
  5. In the dialog, type the name RepaymentAndScore and then click Finish. The decision table editor displays a blank decision table with three empty condition columns and one action column.
  6. Define the first condition column:
    1. Right-click the header of Column A, and then click Edit Condition Column.
    2. Enter the title debt to income.
    3. Enter the following condition test:
      the yearly repayment of 'the loan' * 100 / the yearly income of 'the borrower' is at least <min> and less than <max>
    4. Click Apply, and then OK.
  7. Define the second condition column:
    1. Right-click the header of Column B, and then click Edit Condition Column.
    2. Enter the title credit score
    3. Enter the following condition test:
      the credit score of 'the borrower' is at least <min> and less than <max>
    4. Click Apply, and click OK.
  8. Delete Column C by right-clicking and selecting Remove condition column.
  9. Define the first action column:
    1. Right-click the header of the Action column that is now named C, and click Edit Action Column.
    2. Enter the title message.
    3. Enter the following action:
      add <a string> to the messages of 'the loan'
    4. Click OK.
  10. Create and define a second action column:
    1. Right-click the header of the message column and click Insert Action Column After.
    2. Right-click the header of Action Column D, and then click Edit Action Column.
    3. Enter the title rejected.
    4. Enter the following action:
      reject 'the loan'
    5. Click OK.
  11. Fill rows 1 to 7 with the following data:
    Debt to income Credit score Message Rejected
    0 30 0 200 Debt-to-income too high compared to credit score  
    0 30 200 800    
    30 45 0 400 Debt-to-income too high compared to credit score  
    30 45 400 800    
    45 50 0 600 Debt-to-income too high compared to credit score  
    45 50 600 800    
        0 800 Debt-to-income ratio is greater than 49  
  12. Merge cells with conditions that are common to more than one rule:
    1. Select rows 1 and 2 within column debt to income, right-click, and select Merge.
    2. Do the same for rows 3 and 4, and 5 and 6.
  13. Fill row 7 debt to income values:
    1. Right-click row 7 underneath the min column, and click Operator.
    2. Click ≥ for more than and equal to.
    3. Type 50, press enter.
  14. Disable actions in selected rows:
    1. Right-click row 2 within the message column, and click Enable/Disable Action. A red disable symbol is displayed.
    2. Do the same for rows 4 and 6 in the message column.
    3. Right-click row 2 within the reject column, and click Enable/Disable Action. A red disable symbol is displayed.
    4. Do the same for rows 4 and 6 in the reject column
  15. Format debt to income column:
    • Rows 1 and 2:
      1. Right-click the merged rows 1 and 2, and click Format Cell.
      2. Under Format Statement, within Format, select {0, number, #0.##} , and then type %.
      3. Click OK.
    • Rows 3 and 4:
      1. Right-click merged rows 3 and 4, and click Format Cell.
      2. Under Format Statement, within Format, select {0, number, #0.##} , and then type %.
      3. Click OK.
    • Rows 5 and 6
      1. Right-click the merged rows 5 and 6, and click Format Cell.
      2. Under the Format Statement, within Format, select {0, number, #0.##}, and then type %.
      3. Click OK.
    • Row 7:
      1. Right-click row 7, and click Format Cell.
      2. Under Format Statement, within Format, add % to ≥ {0}
      3. Click OK.
  16. Save your work.
< Previous | Next >