User-Defined Variable Rule Example
This example shows how the value for a named user-defined variable (UDV) is calculated, and how the calculated value can then be used in a decision rule.
A UDV calculation rule can be used to count the number of authorization transactions that take place in a day for an account. The resulting value is used in a case-creation decision rule that generates a case if an account has more than a certain number of transactions in a given day. The rules use a UDV that is named in Account UDV Management in the UDV Management project. The UDV calculation rule is written in the Udv Calculation Ruleset of the Credit 2.5 Authorization-Posting project, and the case-creation rule is written in the Decision Ruleset of the Credit 2.5 Authorization-Posting project.
Rule Narrative
Create a UDV to store an account's transaction count for the day. Create another UDV to store the date of the account's last transaction, which will be used to reset the count each day.
Create a UDV calculation rule to count the number of transactions for the day for each account. First, check if the current transaction is an authorization. If it is, then check to see if the date of the current transaction is the same as the date of the previous transaction. If they are the same, increment the transaction count by 1. If they are not the same, reset the transaction count to 1, and reset the previous transaction date to the current transaction date.
Create a decision rule that says if the current transaction is an authorization and the current transaction count for that account, obtained from the UDV, exceeds 4, then create a case.
UDV Names
The two UDVs are named in Account UDV Management in the UDV Management project, since the values are calculated for each individual account.
The lastTranDate is defined as a Real UDV, so it can be compared to the real number value returned by the Date_Convert function, which is used in the UDV Calculation Rule.
![](GUID-538C481A-4EE3-41DE-BA98-15F1D090AB49-low.png)
The currentDayTranCount is defined as an Integer UDV because it stores the number of transactions.
![](GUID-4EAC8C27-4CCE-40D7-87DF-51B82EC67C84-low.png)
UDV Calculation Rule Code
In the Udv Calculation Ruleset, in the Free Form Editor, the rule can be written as follows:
curDate is a real;
// Date_Convert returns the number of days since 1/1/1990
curDate = Date_Convert(CRTRAN25.transactionDate);
if (CRTRAN25.authPostFlag = "A") then
{
if (ACCT_UDVlastTranDate = curDate) then
ACCT_UDVcurrentDayTranCount += 1;
else {
ACCT_UDVcurrentDayTranCount = 1;
ACCT_UDVlastTranDate = curDate;
}
}
Case Creation Rule Code Using a UDV
In the Decision Ruleset, the rule that uses the currentDayTranCount UDV can be written as follows:
if (CRTRAN25.authPostFlag = "A" and ACCT_UDVcurrentDayTranCount > 4 )
then {TriggerCase(ACCOUNT);}
Components
The named UDVs are accessed by the rules in the data feed project by the name defined in the UDV Management project, prefixed by the UDV category. For this example, account UDVs are prefixed by ACCT_UDV.
Functions:
- Date_Convert converts a dateStr (a string with the format yyyymmdd, where yyyy is the year, mm is the month, and dd is the day). It returns an integer that represents the number of days since January 1, 1990.
- TriggerCase(ACCOUNT) sends a message to create an account case in the Case Manager.