Chapter 22: Working with Contexts in Oracle Fast Formulas
๐ Introduction
In Oracle Fusion Fast Formulas, contexts act as dynamic variables that carry information from the system to your formula during execution. They allow formulas to behave differently based on who or what is being processed—like a specific employee, assignment, or payroll.
๐ง What Are Contexts?
Contexts are predefined variables passed automatically into your formula by the system. These hold values such as:
-
Assignment ID
-
Payroll ID
-
Effective Date
-
Element Type
-
Person ID
These variables help in writing flexible, scalable, and reusable formulas.
๐ Commonly Used Contexts
Context Name | Description |
---|---|
ASSIGNMENT_ID | The assignment being processed |
PERSON_ID | The person for whom the formula is run |
EFFECTIVE_DATE | The current processing date |
ELEMENT_TYPE_ID | The type of element triggering the formula |
PAYROLL_ID | The payroll under which the assignment is processed |
๐ ️ Syntax to Use Contexts
You typically use two statements with contexts:
✅ Example
๐ฆWhy Set Default Values?
If the context value is not passed to the formula, it avoids errors by using a default.
๐ Use Case Example
Let’s say you want to pay a bonus only if a person belongs to Payroll ID 300
.
๐ Best Practices
-
Always provide a default value using
DEFAULT FOR
. -
Use
GET_CONTEXT()
instead of directly referring to the context variable. -
Avoid hardcoding values unless business rules require them.
-
Comment every major logic step for clarity.
๐งช Practice Quiz
-
What is the purpose of using
DEFAULT FOR
in a Fast Formula?-
a) To increase speed
-
b) To add comments
-
✅ c) To avoid errors when context is not passed
-
d) To beautify the code
-
-
What function is used to read a context value?
-
a) READ_CONTEXT
-
✅ b) GET_CONTEXT
-
c) FETCH_CONTEXT
-
d) CONTEXT_VALUE
-
No comments:
Post a Comment