Additional Configurable Validation & Formula Examples

This section provides additional examples for administrators configuring validations and/or formulas in all the Advantage applications excluding Performance Budgeting (PB).

Note: The examples provided in this section and field names used in the expressions are for illustration purposes only. Rule designer must use appropriate field names based on the actual scenarios.

Date UsageDate Usage

Advantage support variety of methods for handling date fields within the expressions. Those include use of simple date literals to advanced date calculations to match all kinds of business requirements.

The following table provides use cases and example expressions for reference.

Using Date Literals

Methods: JAVA method in AMSUtil class.

AMSUtil.getDate(String date) - This method creates a date field using the input literal date value as a string. It is always recommended to pass the date value in MM/DD/YYYY format. For example, 10/01/2019, 12/31/2021.

Validation Examples

Scenario

Expression

Check a date field is after a fixed date.

!empty(DUE_DT) and DUE_DT > AMSUtil.getDate('01/01/2021')

Formula Examples

 

Scenario

Expression

Default a date field value to a fixed date unconditionally.

AMSUtil.getDate('01/01/2019')

Default a date field value to a fixed date conditionally when value is empty.

if (empty(DUE_DT))

AMSUtil.getDate('01/01/2019')

else

DUE_DT

Compare Date Fields

Methods: Both comparation operators (==, <, <=, >, >=) and field level JAVA methods are supported.

<DATE_FIELD>.equals(VSDate anotherDate) - This method checks if the two date fields are equal or not.

<DATE_FIELD>.after(VSDate anotherDate) - This method checks if the date field reference on the left is after the input date provided as a parameter.

<DATE_FIELD>.onOrAfter(VSDate anotherDate) - This method checks if the date field reference on the left is equal or after the input date provided as a parameter.

<DATE_FIELD>.before(VSDate anotherDate) - This method checks if the date field reference on the left is before the input date provided as a parameter.

<DATE_FIELD>.onOrBefore(VSDate anotherDate) - This method checks if the date field reference on the left is equal or before the input date provided as a parameter.

<DATE_FIELD>.daysBetween(VSDate anotherDate) - This method compares a date field reference on the left to the date provided in the parameter and returns the number of days difference between the two dates.

Validation Examples

Scenario

Expression

Check two dates fields are equal. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT == TO_DT

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT.equals(TO_DT)

Check two dates fields are NOT equal. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT != TO_DT

!empty(FROM_DT) and !empty(TO_DT) and !(FROM_DT.equals(TO_DT))

Check a date field after another date field. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT > TO_DT

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT.after(TO_DT)

Check a date field is equal or after another date field. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT >= TO_DT

!empty(FROM_DT) and !empty(TO_DT) and FROM_DT.onOrAfter(TO_DT)

Check a date field is before another date field. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and TO_DT < FROM_DT

!empty(FROM_DT) and !empty(TO_DT) and TO_DT.before(FROM_DT)

Check a date field before or equals to another date field. Use either of the example expressions provided as a reference.

!empty(FROM_DT) and !empty(TO_DT) and TO_DT <= FROM_DT

!empty(FROM_DT) and !empty(TO_DT) and TO_DT.onOrBefore(FROM_DT)

Check days difference between the two date fields.

!empty(FROM_DT) and !empty(TO_DT) and TO_DT.daysBetween(FROM_DT) > 30

Date Calculations

Methods: JAVA methods in AMSUtil class.

AMSUtil.addDays(VSDate inputDate, int daysToAdd) - This method calculates a new date using input date and number of days. A positive value (daysToAdd) advances the date into the future and a negative value calculates the past date from the input date.

AMSUtil.addMonths(VSDate inputDate, int monthsToAdd) - This method calculates a new date using input date and number of months. A positive value (monthToAdd) advances the date into the future and a negative value calculates the past date from the input date.

AMSUtil.addYears(VSDate inputDate, int yearToAdd) - This method calculates a new date using input date and number of years. A positive value (yearsToAdd) advances the date into the future and a negative value calculates the past date from the input date.       

Validation Examples

Scenario

Expression

Check a date field is 45 days after application date using applicationDate keyword. Use either of the example expressions provided as a reference.

!empty(DUE_DT) and DUE_DT > AMSUtil.addDays(applicationDate,45)

!empty(DUE_DT) and DUE_DT.after(AMSUtil.addDays(applicationDate,45))

Formula Examples

Scenario

Expression

Set a date field value to 10 days after another date field value.

if (!empty(START_DT))

AMSUtil.addDays(START_DT, 10)

else

EXPIRE_DT

Set a date field value to 6 months after another date field value.

if (!empty(START_DT))

AMSUtil.addMonths(START_DT, 6)

else

EXPIRE_DT

Set a date field value to 1 year after another date field value.

if (!empty(JOIN_DT))

AMSUtil.addYears(JOIN_DT, 1)

else

PROB_DT

Reading Date Components

Advantage do not support direct methods to read year, month, and day of month of a given date field. Alternatively, date field can be converted to String format and then apply text lookups to extract date values for comparison in validation and/or formulas.  

Methods: JAVA methods in Date Field class and StringUtils class.

<DATE_FIELD>.toShortString() - This method converts referenced date field value into String in the YYYY-MM-DD format.

StringUtils.startsWith(CharSquence inputText, CharSequence prefix) - Checks if an input text starts with the prefix.

StringUtils.endsWith(CharSequence inputText, CharSequence suffix) - Checks if an input text ends with the suffix.

StringUtils.substring(CharSequence inputText, int start, int end) - Gets a substring from the specified input String. The returned substring starts with the character in the start position and ends before the end position. All position counting is zero-based, that is, to start at the beginning of the string use start = 0. Negative start and end positions can be used to specify offsets relative to the end of the String.       

Validation Examples

Scenario

Expression

Check a date is in a specific year. Use either of the example expressions as a reference.

!empty(EFFECTIVE_DT) and StringUtils.startsWith(EFFECTIVE_DT.toShortString(),'2022')

!empty(EFFECTIVE_DT) and StringUtils.substring(EFFECTIVE_DT.toShortString(),0,4) == '2022'

Check a date is in a specific month.

!empty(EFFECTIVE_DT) and StringUtils.substring(EFFECTIVE_DT.toShortString(),5,7) == '06'

Check day of the month in a date. Use either of the example expressions as a reference.

!empty(EFFECTIVE_DT) and StringUtils.endsWith(EFFECTIVE_DT.toShortString(),'30')

!empty(EFFECTIVE_DT) and StringUtils.substring(EFFECTIVE_DT.toShortString(),8,10) == '30'

Check a date not starting on a specified month and day. User either of the example expressions as a reference

!empty(EFFECTIVE_DT) and StringUtils.endsWith(EFFECTIVE_DT.toShortString(),'07-01')

!empty(EFFECTIVE_DT) and (StringUtils.substring(EFFECTIVE_DT.toShortString(),5,7) != '07' or StringUtils.substring(EFFECTIVE_DT.toShortString(),8,10) != '01')

Formula Examples

Scenario

Expression

Set the year value of a date field in another field. If target field stores a number, value must be converted to a number.

if (!empty(START_DT))

StringUtils.substring(START_DT.toShortString(),0,4)

else

YEAR

Set the month value of a date field in another field. If target field stores a number, value must be converted to a number.

if (!empty(START_DT))

StringUtils.substring(START_DT.toShortString(),5,7)

else

MONTH

Set the day of month value of a date field in another field. If target field stores a number, value must be converted to a number.

if (!empty(START_DT))

StringUtils.substring(START_DT.toShortString(),8,10)

else

DAY

Text Field UsageText Field Usage

The following table provides examples for validating String or Text type of fields within the expression.

Matching Value

Methods: Both rule engine operators and StringUtils class methods supported.

Operators:

=^ - Checks field value starts with a search String.

!^ - Checks field does not start with a search String.

=$ - Checks field value ends with a search String.

!$ - Checks field does not end with a search String.

JAVA methods:

StringUtils.startsWith(CharSquence inputText, CharSequence prefix) - Checks if an input text starts with a prefix.

StringUtils.endsWith(CharSequence inputText, CharSequence suffix) - Checks if an input text ends with a suffix.

StringUtils.contains(CharSequence inputText, CharSequence searchText) - Checks if an input text contains matching search text anywhere in the value. Search is case-sensitive.

Validation Examples

Scenario

Expression

Check a text field value starts with a specified prefix. Use either of the example expressions provided as a reference.

Note: To check for multiple prefixes, repeat the condition using and/or operation as needed.

PSCD_CD =^ 'BFY'

StringUtils.startsWith(PSCD_CD, 'BFY')

Check a text field value does NOT starts with a specified prefix. Use either of the example expressions provided as a reference.

Note: To check for multiple prefixes, repeat the condition using and/or operation as needed.

PSCD_CD !^ 'BFY'

!(StringUtils.startsWith(PSCD_CD, 'BFY'))

Check a text field value end with valid suffix value. Use either of the example expressions provided as a reference.

Note: To check for multiple suffixes, repeat the condition using and/or operation as needed.

PSCD_CD =$ 'BFY'

StringUtils.endsWith(PSCD_CD, 'BFY')

Check a text field value end with valid suffix value. Use either of the example expressions provided as a reference.

Note: To check for multiple suffixes, repeat the condition using and/or operation as needed.

PSCD_CD !$ 'BFY'

!(StringUtils.endsWith(PSCD_CD, 'BFY'))

Check a text field contains a specific text anywhere in the value.

Note: To check for multiple search criteria, repeat the condition using and/or operation as needed.

StringUtils.contains(DOC_NM, 'HELLO')

Check a text field does NOT contain a specific text anywhere in the value.

Note: To check for multiple search criteria, repeat the condition using and/or operation as needed.

!(StringUtils.contains(DOC_NM, 'HELLO'))

Change Case

Methods: StringUtils class methods.

StringUtils.upperCase(CharSquence inputText) - Converts input text to upper case.

StringUtils.lowerCase(CharSequence inputText) - Converts input text to lower case.

Validation Examples

Scenario

Expression

Case-insensitive match on a text field value that allows mixed case with an upper case.

!empty(FIRST_NM) and StringUtils.upperCase(FIRST_NM) == 'JOHN'

Case-insensitive match on a text field value that allows mixed case with lower case.

!empty(FIRST_NM) and StringUtils.lowerCase(FIRST_NM) == 'john'

Formula Examples

Scenario

Expression

Set a field value that allows mixed case to upper case value.

StringUtils.upperCase(FIRST_NM)

Set a field value that allows mixed case to lower case value.

StringUtils.lowerCase(FIRST_NM)

Set upper case value of a field in another field.

if (!empty(FIRST_NM))

StringUtils.upperCase(FIRST_NM)

else

FIRST_NM_UP

Pattern Matching

You can use regular expression (REGEX) search patterns against a text field to match specific patterns in the value. This capability opens up infinite options to validate a field value for different needs. However, you should be familiar with the REGEX syntax to fully utilize the capabilities. The following table provides simple examples for reference.

Methods: Rule engine operators.

=~ Can be used to check that a String matches a regular expression.

!~  Can be used to check that a String does not match a regular expression.

Validation Examples

Scenario

Expression

Check for a field value contains numbers.

Let’s break the regex and understand,

  • .* Optional, any character sequence before the digit

  • \\d+ At least one-digit occurrence

  • .* Optional, any character sequence after the digit

EMPL_FIRST_NM =~ '.*\\d+.*'

Example values and result using above pattern matching.

EMPL_FIRST_NM

Result

1John

John2

Jo12hn

true

John

false

 

Check for phone number field NOT matching 10-digit phone number with white spaces, hyphens or no spaces.

Let’s break the regex and understand,

  • ^ start of expression

  • d{3} is mandatory match of 3 digits

  • [- ]? is optional match of whitespace or hyphen after 3 digits

  • {2} is to repeat the above match d{3}[- ]? two times becomes total 6 digits

  • d{4} is mandatory match of last 4 digits

  • $ end of expression

PHONE_NO !~ '^(\\d{3}[- ]?){2}\\d{4}$'

Example values and result using above pattern matching.

PHONE_NO

Result

703 267 8000

703-267-8000

7032678000

false

703.267.8000

703-A67-8000

true

 

List of ValuesList of Values

You can compare a field value against a list of values that behave like “in” or “not in” matching. Values are comma separated and wrapped inside square brackets. However, when providing list of values within the expression, values must match the data type of the field being compared to avoid incorrect results.

Note: Date fields cannot be compared against a list of values.

The following table provides examples for reference.

Methods: Rule engine operators.

=~ Checks whether a collection contains a value or not. It behaves as an “in” operator.

!~  Checks whether a collection does not contain a value. It behaves as “not in” operator.

Validation Examples

Scenario

Expression

Check for a text field value is in list of values.

PERS_ACTN_RSN_CD =~ ['B1', 'B2', 'B3']

Check for a text field value is NOT in list of values.

PERS_ACTN_CD !~ ['33', '34']

Check for a Big Decimal or Currency field in list of values. Suffix b indicates the rule engine to interpret value as Big Decimal.

FT_PC =~ [0.25b,0.5b,075b,1b]

Check for a Big Decimal or currency field NOT in list of values.

FT_PC !~ [0.25b,0.5b,075b,1b]

Check for a Number field is in list of values.

FUND_PRTY =~ [1,2,3]

Check for a Number field is NOT in list of values.

FUND_PRTY !~ [1,2,3]

Check for a valid combination of two field values.

PERS_ACTN_CD == '06' and PERS_ACTN_RSN_CD !~ ['F1', 'F2', 'F3','F4']

Parent LookupsParent Lookups

You can read parent object instance to compare parent field values within the expressions. However, you need to be aware of the JAVA method to use for parent lookup in each instance where a validation or formula configured. The naming of JAVA method determined using relationship metadata configured between related business objects. Also, when referring to parent object fields, expression must use get<column_name>() method to read a parent field value.  

Methods: JAVA method available on business object instance which can be invoked using this prefix.

The following example methods are for the Accounting Based Spending (ABS) transaction business objects.

Relationship

Method Name

From Vendor Line (ABS_DOC_VEND), lookup Header (ABS_DOC_HDR) record

this.getABSVendToABSHdr()

From Accounting Line (ABS_DOC_ACTG), lookup Vendor (ABS_DOC_VEND) record

this.getABSActgToABSVend()

From Accounting Line (ABS_DOC_ACTG), lookup Header (ABS_DOC_VEND) record

this.getABSActgToABSVend().getABSVendToABSHdr()

Validation Examples

Scenario

Expression

Disbursement Type on Vendor line should not be EFT (4) when Bank Account selected on Header is 001.

DEFT_DISB_TYP == 4 and this.getABSVendToABSHdr().getBANK_ACCT_CD() == '001'

Formula Examples

Scenario

Expression

Default Disbursement Type to Check (1) on Vendor if Bank Account selected on Header equals to 005.

if (this.getABSVendToABSHdr().getBANK_ACCT_CD() == '005')

1

else

DEFT_DISB_TYP

Default Bank Account on Accounting Line to 96 if Disbursement Format Type equals PAYP on Vendor.  

if (this.getABSActgToABSVend().getDFLT_DISB_FRMT() == 'PAYP')

  return '96'

else

BANK_ACCT_CD