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.
- Click on Rules in the left-hand navigation panel
- Click Add button and select Invoice
- A RuleSet has been created. Rename the ruleset from "RuleSet" to "ValidateInvoice"
- Add a syntax rule by clicking the Add button or right click on the ruleset and select Add. Select If Then
- Set the If expression to CustName = "" And Not(IsNull(CustID))
- Next to the Then section, click the Add button, select Actions -> Set Field Invalid
- Set the Field to CustID and the Message to: The Customer ID <%CustID%> is not a valid ID
- 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
- 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:
- 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
- Add another rule set under the Invoice entity and call it "AwardRules". Set the run mode to Optimized
- Add another If Then rule, where the If expression is Invoice.SubTotal > 10
- 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."
- 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))
- 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.
- 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:
Now, you can move onto the last step of this tutorial, where you will Test the Rule Application.
Comments
0 comments
Article is closed for comments.