Creating Custom Messages with Sample Formula

In absence management, we can configure custom error messages to restrict users from applying absence for some specific conditions
Example: I don’t want user to apply for absence for previous year or future year.
So I can write a custom logic in fast formula and configure a custom error message telling user that the absence can be applied for the current year 2017.



For creating custom error message, we need to go to Setup and maintenance > Manage messages >  Create

Message Name
XX_TEST_VALID
Application
Absence Management
Module
Application Common
Message Number
10000014
Message Type
Error
Logging Enabled
Yes
Short Text
You cannot record this absence. Apply for current year absence.

The error message can be included in a custom fast formula in the following way:

/* Formula Name: XX_TEST_VALID_FF
Formula Type: Global Absence Entry Validation */

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
(
VALID = 'Y'
)
ELSE
(
                VALID ='N'
                ERROR_MESSAGE = ' XX_TEST_VALID '
)
Return VALID, ERROR_MESSAGE


 When the user applied for absence for the next year, the application throws the error message as

Error
You cannot record this absence. Apply for current year absence.(ANC 10000014)


This helps the user understand what is stopping the them from applying the absence.

Comments