Oracle Fast Formulas - Chapter 25: Global Variables and Contexts in Fast Formulas

 

Chapter 25: Global Variables and Contexts in Fast Formulas

๐ŸŒ Introduction

In Oracle Fusion Fast Formulas, global variables and contexts play a key role in dynamically retrieving system and user-specific data during formula evaluation. They allow formulas to access predefined values without manual input, making them highly adaptable for various HCM and payroll processing requirements.


๐Ÿ”‘ Global Variables

Global variables are predefined system variables provided by Oracle based on the type of formula being executed. These variables do not require declaration and are automatically made available in the formula context.

๐Ÿ“Œ Characteristics:

  • Read-only

  • Provided by Oracle

  • Automatically available

  • Formula-type dependent

๐Ÿ’ก Common Examples:

Variable NameDescription
ASSIGNMENT_IDID of the assignment being processed
EFFECTIVE_DATEThe date for which the formula is executed
PAYROLL_IDPayroll ID assigned to the employee
ELEMENT_NAMEName of the element (if applicable)

These variables simplify access to core information without extra setup.


๐Ÿงญ Contexts in Fast Formulas

Contexts are dynamic values that provide additional runtime data such as person, assignment, or legal entity. You can default them and access their values using CONTEXTS.<name> syntax.

✅ How to Define and Use a Context:

DEFAULT FOR CONTEXTS.ASSIGNMENT_ID IS 0 DEFAULT FOR CONTEXTS.EFFECTIVE_DATE IS '1900/01/01' ASSIGNMENT_USED = CONTEXTS.ASSIGNMENT_ID

This example defaults the context to a known value and retrieves the runtime value using the CONTEXTS keyword.


๐Ÿง  Difference Between Global Variables and Contexts

FeatureGlobal VariablesContexts
Declaration Needed❌ No✅ Yes (DEFAULT FOR)
Editable❌ Read-only✅ Custom defaults allowed
Formula Type Dependent✅ Yes✅ Yes
Use CaseSystem-provided valuesRuntime data based on inputs

๐Ÿงช Practical Example

Here’s a simple Fast Formula example that checks if an employee’s assignment ID is within a certain range:

DEFAULT FOR CONTEXTS.ASSIGNMENT_ID IS 0 IF CONTEXTS.ASSIGNMENT_ID > 1000 THEN RETURN 'VALID' ELSE RETURN 'INVALID'

๐Ÿ“ Summary

  • Global Variables are pre-populated and read-only.

  • Contexts allow for flexible data retrieval and need default values.

  • Both are essential for dynamic formula behavior.

  • Using contexts appropriately helps avoid hardcoding values and improves reusability.

Chapter 25 Practice Quiz: Global Variables and Contexts

Question 1:
Which of the following statements about global variables is true?
A. They must be declared before use
B. They are editable during runtime
C. They are automatically provided by Oracle
D. They are used to store user passwords

๐ŸŸฉ Answer: C


Question 2:
What keyword is used to assign a default value to a context in Fast Formulas?
A. SET
B. INIT
C. DEFAULT FOR
D. CONTEXT ASSIGN

๐ŸŸฉ Answer: C


Question 3:
Fill in the blank:
Contexts are accessed in Fast Formulas using the prefix __________.

๐ŸŸฉ Answer: CONTEXTS.


Question 4:
Which is not a correct use of a context variable?
A. DEFAULT FOR CONTEXTS.EFFECTIVE_DATE IS '2020/01/01'
B. MY_VAR = CONTEXTS.ASSIGNMENT_ID
C. DEFAULT CONTEXTS.PERSON_ID IS NULL
D. RETURN CONTEXTS.EFFECTIVE_DATE

๐ŸŸฉ Answer: C — because it misses the FOR keyword.


Question 5 (True/False):
Global variables can be modified by the formula writer during execution.

๐ŸŸฉ Answer: False

No comments:

Post a Comment