Oracle Fast Formulas - Chapter 13: Working with Global Variables and Contexts in Fast Formulas

 

Chapter 13: Working with Global Variables and Contexts in Fast Formulas


🎯 Objective of This Chapter

This chapter will teach you how to use global variables and context variables in Oracle Fusion Fast Formulas to make formulas dynamic, reusable, and capable of adapting to different processing environments.


🧠 What Are Global Variables?

Global variables are predefined keywords or data that are accessible across formulas. They help you:

  • Retrieve values like legislative data group (LDG), effective dates, payroll IDs

  • Write conditionally responsive formulas

  • Ensure formulas adapt to system-wide configurations


Commonly Used Global Variables

Variable NameDescription
GLOBAL_CONTEXT.LEGISLATIVE_DATA_GROUP_IDLegislative group ID for current run
GLOBAL_CONTEXT.ASSIGNMENT_IDAssignment ID in current process
GLOBAL_CONTEXT.EFFECTIVE_DATEEffective date for current calculation

🧠 What Are Context Variables?

Context variables are inputs passed by the Oracle Fusion system based on the environment where the formula is used (e.g., Payroll, Compensation, Benefits).

They allow you to:

  • Detect current assignment

  • Respond to payroll frequency

  • Adjust logic based on plan or element


Setting Context in Fast Formulas

Before using a context variable, it must be declared:

DEFAULT FOR CONTEXT_VARIABLE IS <value>

Example:

DEFAULT FOR CONTEXT.EFFECTIVE_DATE IS '1951/01/01'

💡 Example: Using Context and Global Variables

Scenario:

Apply different salary calculations based on legislative group.


Code Snippet:

DEFAULT FOR GLOBAL_CONTEXT.LEGISLATIVE_DATA_GROUP_ID IS 0 IF GLOBAL_CONTEXT.LEGISLATIVE_DATA_GROUP_ID = 101 THEN SALARY_BONUS = 2000 ELSE SALARY_BONUS = 1000 RETURN SALARY_BONUS

Explanation:
This formula checks the LDG and assigns a bonus accordingly.


✅ Best Practices

  • Always assign default values to context/global variables.

  • Use context to control logic without multiple formulas.

  • Test formula outputs under different contexts.


🔁 Real-World Use Case

You can use context variables to define different behaviors in:

  • Payroll Processing

  • Compensation Management

  • Absence Calculation

  • Benefits Eligibility


📝 Mini Practice Quiz

  1. What is the purpose of global variables in Fast Formulas?
    👉 To access system-wide values like LDG, Assignment ID.

  2. What should you always provide to a context variable?
    👉 A default value.

  3. Can context variables be reused in different formula types?
    👉 Yes, but they must be declared appropriately.

No comments:

Post a Comment