< Previous | Next >

Implementing the business rule for automatic approval

In this lesson, you will set up a business rule to allow automatic approval of certain orders.

The business rules task uses the Order business item as the input and checks the TotalPrice variable. If the total price is less than or equal to a specified fixed amount (in this case $750.00), then the rules task sets the AutomaticApproval variable in the Order business item to true; otherwise, the variable is set to false. The business rules component returns the modified Order business item as the output.

To implement the business rules task, you will first create a template and then create an if-then rule instantiating the template.

  1. In the process diagram, click the Check Order Handling Policy for Automatic Approval task and then, in the Attributes view, click the Business Rules tab.
  2. Click Add. The Define Business Rule wizard opens.
  3. Enter AutoApprovalF1 as the name of the business rule.
  4. Click the Rule Templates tab and then click Add Template.
  5. Change the template name from Rule template:1 to AutoApproval Template by selecting the name and typing over it.
  6. Under Rule parameters, click Add.
  7. Define the rule parameter by completing the following steps:
    1. Change the parameter name to totalPriceMax by selecting it and typing over the generated name.
    2. Select Decimal (double-precision) as the type.
    3. For the description, enter maximum purchase price for automatic approval.
      Automatic approval in the business rule
  8. In the Rule Templates table, click the rule condition cell for AutoApproval Template and then click the Edit icon to open a Rule Condition wizard.
  9. In the Expression Builder for the rule condition, complete the following steps:
    1. Add a simple binary expression by clicking Add.
    2. For the first term, select Modeling Artifact. Expand Check Order Handling Policy for Automatic Approval > Input and select TotalPrice.
    3. For the Operator, select is less than or equal to.
    4. For the second term, select Modeling Artifact. Expand Check Order Handling Policy for Automatic Approval and select totalPriceMax.
      Expression Builder (for the rule condition) with settings
    5. Click Apply, and then click OK.
  10. Click in the Rule action cell for AutoApproval Template and then click the Edit icon.
    AutoApproval Template
    The Specify Rule Action wizard opens.
  11. Specify the rule action by completing the following steps:
    1. Expand and select Check Order Handling Policy for Automatic Approval > Output > OrderProcessingPreference > automaticApproval. Then select Value specification > Specific value and True. Click OK.
      Specify Rule Action wizard

      The following figure shows the completed business rule template.

      Completed business rule template

    You must now create an if-then instance of this rule template.
  12. Click the If-Then Rules tab.
  13. Click Add Rule.
  14. Change the name of the new rule to AutoApprove Rule.
  15. For Template name select AutoApproval Template.
  16. After selecting the template, a pop-up will ask if you want to overwrite the rule conditions and actions, click OK. This will fill in the rest of the fields.
  17. Under Rule parameter values, change the Value of totalPriceMax from 0.0 to 750.0 The following image shows the completed business rule.Complete business rule
  18. Close the Define Business Rule wizard by clicking OK.
  19. In the Attributes view, select the Business Rules tab and scroll down to the Scheduling section. For Default business rule, select AutomaticApprovalF1 from the list. Save your work.
    Attributes of AutomaticApprovalF1
< Previous | Next >