Oracle Fast Formulas - Chapter 8: Contexts in Fast Formulas

  

Chapter 8: Contexts in Fast Formulas


Objective of This Chapter

This chapter explains Contexts in Oracle Fusion Fast Formulas — what they are, how they work, and how to use them smartly in your formulas.


What are Contexts

  • Contexts are automatic inputs available to your formula based on the environment it is running in.

  • They provide extra dynamic information without needing manual inputs.

  • Contexts help formulas behave differently depending on person, assignment, payroll, or other conditions.


How Contexts Work

When you run a formula, Fusion automatically passes some environment-specific values like:

Context NameMeaning
ASSIGNMENT_IDAssignment ID of the employee
EFFECTIVE_DATEEffective date of calculation
BUSINESS_GROUP_IDBusiness Group linked to employee
PAYROLL_IDPayroll record being processed

You can access these contexts in your formula just like normal variables.


Setting Contexts Explicitly

In case your formula needs to ensure a context is available, you can declare it using:

CHANGE CONTEXTS ARE assignment_id, effective_date

This makes the formula more controlled.


Example of Using Contexts

Suppose you want to calculate a bonus only for employees assigned to a particular payroll:

CHANGE CONTEXTS ARE payroll_id IF payroll_id = 5001 THEN bonus = salary * 0.20 ELSE bonus = 0 RETURN bonus

Here, the formula reads payroll_id automatically without passing it as an input.


Types of Common Contexts

TypeExample Fields
Assignmentassignment_id, job_id
Payrollpayroll_id, effective_date
Peopleperson_id, person_number
Otherslegislation_code, business_group_id

Important Rules

RuleReason
Always use CHANGE CONTEXTS to declareTo make your formula clean and explicit
Validate context valuesAvoid unexpected errors
Understand which module gives which contextPayroll, Absence, Benefits, etc.

Benefits of Using Contexts

  • Reduces the number of manual inputs.

  • Makes formulas more dynamic.

  • Improves performance because system data is directly used.

  • Easier maintenance when business logic changes.


Simple Practical Example

Bonus calculation based on Job:

CHANGE CONTEXTS ARE job_id IF job_id = 1001 THEN bonus = salary * 0.15 ELSIF job_id = 1002 THEN bonus = salary * 0.10 ELSE bonus = salary * 0.05 RETURN bonus

Mini Practice Quiz

  1. What keyword is used to mention that a context will be used?
    A CONTEXTS
    B CHANGE CONTEXTS ARE
    C ENVIRONMENT

Answer: B CHANGE CONTEXTS ARE

  1. Which of these is an example of a context?
    A salary
    B assignment_id
    C bonus

Answer: B assignment_id

  1. True or False: Contexts need to be passed manually every time.
    Answer: False

No comments:

Post a Comment