Create Rules

  • Updated

In this section you will learn how to create rules. You actually have already created rules in Step 1, because you created Calculations, which can also be implemented as a rule, and vice versa. Rules can either be implemented as "syntax" rules or "business language" rules. We will show an example of both of these types of rules.

  1. Click on Rules in the left-hand navigation panel
    ri_65.png
  2. Click Add button and select Invoice
    ri_66.png
  3. A RuleSet has been created. Rename the ruleset from "RuleSet" to "ValidateInvoice"
  4. Add a syntax rule by clicking the Add button or right click on the ruleset and select Add. Select If Then
    ri_67.png
  5. Set the If expression to CustName = "" And Not(IsNull(CustID))
  6. Next to the Then section, click the Add button, select Actions -> Set Field Invalid
    ri_68.png
  7. Set the Field to CustID and the Message to: The Customer ID <%CustID%> is not a valid ID
    ri_69.png
  8. We'll now implement the same rule as above, but instead of a syntax rule, it will be a language rule. Click on the ruleset ValidateInvoice, in the left-hand navigation pane. Add a business rule by clicking the Add button or right click on the ruleset and select Add. Select Language Rule
    ri_70.png
  9. Rename the rule to ValidateCustomer. Click on [Create Rule] to get started. Build the language rule to accomplish the same logic as the syntax rule. The business language is shown below:
    ri_71.png
  10. Now the ValidateInvoice rule set has two rules within it that do the same thing. Let's disable the syntax rule. Click on the first rule in that rule set and uncheck the Enabled checkbox
    ri_72.png
  11. Add another rule set under the Invoice entity and call it "AwardRules". Set the run mode to Optimized
    ri_73.png
  12. Add another If Then rule, where the If expression is Invoice.SubTotal > 10
  13. Next to the Then section, click the Add button, select Actions -> Fire Notifcation. Name the notification "NotifyAwardProgram", set the Type to Informational, and set the Message to "Customer is qualified to participate in the Gold Member Awards program."
    mceclip1.png
  14. Add a rule set under the LineItem entity and call it "ValidateLineItem". Add an If Then rule, where the If expresssion is ProductName="" And Not(IsNull(ProductID))
  15. Next to the Then section, click the Add button, select Actions -> Set Field Invalid. Set the field to ProductID and the Message to: The product ID <%ProductID%> was not found.
    mceclip2.png
  16. Save the rule application by clicking the Save button in the Quick Access Toolbar

At this point, your Rules in the left-hand navigation pane should look like this:

mceclip3.png

Now, you can move onto the last step of this tutorial, where you will Test the Rule Application.

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.