Fast formulas exist not only for payroll calculation but also for many other purposes. One of them being input value validation i.e. using these type of formulas we will be able to validate the screen entry values of element's input values.
We can add these validations against particular elements in
Form Functions(ctrl + L) -> element entries
Here search for the person and select the element's entry value button and in the popup form, horizontal scroll to formula text box and from the LOV select the formula which validates the screen entries against this input value.
Such custom formula can be created in
Form Functions(ctrl + L) -> write formula
Create the formula with formula type as Element Input Validation. A very useful article on element input validation formulas can be found in
oracle manual here.
Two basic rules for writing an input value validation formula are
-
There should be only one INPUT for the formula named ENTRY_VALUE of text data type i.e. INPUTS are entry_value(text)
-
entry_value input can be converted to number types using to_num conversion functions for any validation
-
There should be a mandatory return parameter called formula_result that can take either ‘S’ (success) or ‘E’ (error)
Let us consider an example of validating an entry value which must be atleast 10 i.e. consider an HRA element where we will be using this validation to enforce a rule that the employee gets a minimum of 10% HRA. A simple formula validation may be as follows
INPUTS are Entry_Value(text)
FORMULA_RESULT = ‘S’
IF TO_NUM(Entry_Value) < 10 THEN
(
FORMULA_RESULT = ‘E’
FORMULA_MESSAGE = ‘Entry Value must be minimum 10 and above’
)
RETURN FORMULA_RESULT, FORMULA_MESSAGE
After attaching this above formula against hra_pct of test_hra and when used for an employee, the above validation is fired whenever we enter some screen entry value for the hra_pct. Notice that when hra_pct value entered is less than 10, application throws error from the formula_message but eventually saves the transaction.
The formula validation we try to do will merely give warning to the user and no way prevent one from overriding the formula validation.