Finally, you have arrived at the fraud detection rule itself. In the FraudDetection rule you will use a few standard functions, along with the values in an Account concept instance, and the FraudCriteria scorecard to calculate whether recent activity indicates possible fraud.This task provides summary instructions for actions you have already learned. If you need a reminder, refer to Task H for details.
1. Add another rule to the ProcessDebits rule set and name it FraudDetection.
2. Open the rule editor for the FraudDetection rule.
3. In the Alias column, the alias is automatically set to account. The alias is used to refer to this concept in the rule action area.
4. In the top right of the user interface, click Standard > Temporal > History and then hover the cursor over howMany to see the signature of this standard function and understand the purpose of its parameters.
5. Drag the howMany() function into the Conditions area. The characters Temporal.History.howMany appear.
6. Complete typing the first condition as shown below. You can drag the DateTime functions onto the rule editor, or type the names. Add an annotation to make the rule easier to read.
The above condition checks whether the number of debits in the specified interval prior to the current time is greater than the specified number of debits. The interval and the number of debits are set in the FraudCriteria scorecard.
// 2. Checks the percentage of the average balance that was debited in the verification interval
This condition checks whether the sum of all debits in the verification interval is greater than the specified percentage of the account average monthly balance. The specified percentage is set in the FraudCriteria scorecard. The average monthly balance, for the purposes of this tutorial, is set in the Account instance created by the InitializeAccounts rule function.Note that a rule can specify multiple conditions and all conditions in a rule must be met, before the action is done. That is, each condition is joined by an implied "AND" operator.
System.debugOut("############### Account Id <"+account@extId+"> STATUS set to <Suspended>. Fraud suspected.");
When an account debit event arrives, and the account fails the verification tests set in the conditions, the status is set to Suspended, and a message prints to the console.
9. Click Apply and save the project.Summary and Next StepsYou will define one more rule, to set the account status to Suspended if the account balance goes negative.
Copyright © TIBCO Software Inc. All Rights Reserved.