Absence Entry Validation Fast Formula for Current Year Validation


Business Requirement: Checks if the absence entered is in the Current Year.

Solution: Write a Global Absence Entry Validation Fast Formula and attach it to the Absence Type Created. When the user applies for absence( in this case Annual Vacation, Purchased Time Off) on any other date than the current year dates then the application throws a custom error message "Apply absence for current calendar year 2017.".

Sample Formula: Global Absence Entry Validation Fast Formula for Current Year Validation


DEFAULT for ANC_ABS_TYP_NAME IS ' '
DEFAULT for GLOBAL_PAY_INTERFACE_EXTRACTION_DATE IS ' '

INPUTS ARE IV_END_DATE (date), IV_START_DATE (date)

l_system_date = TO_DATE(GLOBAL_PAY_INTERFACE_EXTRACTION_DATE,'YYYY/MM/DD')
l_system_year = TO_NUMBER(TO_CHAR(l_system_date,'YYYY'))
l_absence_start_year = TO_NUMBER(TO_CHAR(iv_start_date,'YYYY'))
l_absence_end_year = TO_NUMBER(TO_CHAR(iv_end_date,'YYYY'))

IF(l_absence_start_year = l_system_year) AND (l_absence_end_year = l_system_year) THEN
(
               
                IF(ANC_ABS_TYP_NAME = 'Annual Vacation' OR ANC_ABS_TYP_NAME = 'Purchased Time Off' ) THEN
                                (
                                                VALID = 'Y'
                                )
               
)
ELSE
(
                VALID ='N'
                ERROR_MESSAGE = ('Apply absence for current calendar year '||to_char(l_system_year)||'.')
               
)

Return VALID, ERROR_MESSAGE



Comments