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

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.

  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 opens in the default editor. The table shows three empty condition columns, and one empty action column.
  6. Define the first condition column:
    1. Right-click the header of first column, and then enter the title debt to income.
    2. Enter the following condition test in the edit bar:
      the yearly repayment of 'the loan' * 100 / the yearly income of 'the borrower' is at least <min> and less than <max>
    3. Click OK.
  7. Define the second condition column:
    1. Right-click the header and enter the title credit score.
    2. Enter the following condition test:
      the credit score of 'the borrower' is at least <min> and less than <max>
    3. Click OK.
  8. Delete the third condition column by right-clicking the column header and selecting Delete from the menu.
  9. Define the first action column:
    1. Right-click the header of the first action column and enter the title message.
    2. Enter the following action:
      add <a string> to the messages of 'the loan'
    3. Click OK.
  10. Create and define a second action column:
    1. Right-click the header of the message column and click Insert column > Action after.
    2. Right-click the header of the new column, and enter the title rejected.
    3. Enter the following action:
      reject 'the loan'
    4. 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  
    Tip: You can copy and paste the data in the first cell of the decision table.
  12. 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.
  13. Disable actions in selected rows:
    1. Right-click row 2 within the message column, and click Disable. 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 Disable. A red disable symbol is displayed.
    4. Do the same for rows 4 and 6 in the reject column
  14. Format debt to income column:
    1. Right-click the header of the column.
    2. Click Format column.
    3. Enter the following format {0, number, #0.##} .
    4. Click OK to save your changes.
  15. Save your work.
Related conceptsRule authoring for COBOL compatibility