The condition is an expression that can evaluate to true or false. The action sets the result data.
How to do it...
I. Creating a rules dictionary
Start Oracle JDeveloper, select Default Role, and click OK.
Go to Application Navigator | Project and click on the process SalesToContract.
Go to Component Palette | BPM and click on Business Rule from Activities.
Click in the BusinessAnalyst swimlane, above the Is Business Analyst Review Required? gateway.
You will find the BusinessRuleTask Properties dialog.
Enter the Business Rule Task name as DiscountCheck.
Click on the Implementation tab and click the green plus (+) icon to add a Business rule.
You will find that a Create Business Rule dialog opens up.
Go to the General tab of the dialog and enter a rule name DiscountCheck.
In the Input and Output section click on the green plus (+) icon to add input and output Data objects.
Click Input Data Object, browse for Quote, click Output Data Object, and browse for the ApprovalFlow object as the input and output of the Business rule.
Click OK.
In the Properties dialog, you will create a Data association. Click on the pencil icon to the right of Use Associations to check Data association.
You can find the quote and ApprovalFlow objects as input and output for the DiscountCheck rule, respectively.
When finished, Save.
Go to BPM Project navigator | Business Catalog | Rules and you will find a DiscountCheck.rules file has been created. This is the rules dictionary.
Create unconditional sequence flows as follows:
Sequence flow from the CheckCustomerType gateway to DiscountCheck
Sequence flow from DiscountCheck to the Is Business Analyst Review Required? gateway
Sequence flow from CustomerCheckOutcome to DiscountCheck
The process will resemble the following screenshot:
II. Defining Globals
In Oracle Business rules, a Global is similar to a public static variable in Java. You will create a Global to hold Customer Type values, as follows:
Global Name
Type
Value
Final
Discountvar
Double
30
Checked
Go to BPM Project Navigator | Rules and click DiscountCheck.rules. This will open the Rule designer.
Click on Globals in the Rule designer.
Click on the green plus(+) icon to create a Global.
Enter details as described in the preceding table.
In the Value field, click the Expression Builder icon to enter an expression, enter a value, 30, and check Final and Constant. Checking Final means the global is non-modifiable.
When you have finished this, Save.
III. Defining Rules
Go to the Rule designer for DiscountCheck.rules and select Rulesets | Ruleset1.
Click on Create Rule, to create an IF/THEN rule for this ruleset.
Name the ruleset as DiscountCheckRuleSet, and enter CheckDiscount as name of the IF/THEN rule.
Click on the green plus (+) icon to create another IF/THEN rule for this ruleset, and name it CheckDiscountNP.
In the If section for the CheckDiscount rule, click<insert text> and enter an IF condition, as follows:
QuoteRequestType.summary.effectiveDiscount>= Discountvar and
QuoteRequestType.summary.customerType == "Premium"
In the Then section, click<edit properties>. It will open Properties for ApprovalFlowType; enter values for businessPractiseReviewNeeded = false and check Constant value:
asset new ApprovalFlowType(<editproperties>businessPractiseReview Needed:false)
In the IF section for the CheckDiscountNP rule, click<insert text> and enter an IF condition, as follows:
QuoteRequestType.summary.effectiveDiscount>= Discountvar and
QuoteRequestType.summary.customerType != "Premium"
In the Then section, click<edit properties>. It will open Properties for ApprovalFlowType. Enter values for businessPractiseReviewNeeded = true and check Constant value.
How it works...
When the process token reaches DiscountCheck, the If-Then-Else ruleset gets evaluated. If the effective discount is greater than 30% and the customer is a Premium customer, then a business analyst review is not required. The token moves to the Approvals Gateway.
If the effective discount is greater than 30% and customer is not a Premium customer, then a business analyst review is required. The token moves to the task Business Analyst Review.