Apex Trigger Practice (4)

Prerequisites

  • Standard Contact Object
    • There is checkbox Field on Contact called “Active”
  • A custom object “Employment Detail” as child object of Contact Object
    • There is a picklist field “Status” having two values: Employee, Ex-Employee
    • And a lookup field to Conatct

Requirement:

If Contact field “Active” is marked as true, then

  • If no record of child object “Employment Detail” exists, then create a record with Status = “Employee”
  • If record exists already then make sure field “Status” Employment Detail is marked as “Employee”

If Contact field “Active” is marked as false, then

  • If no record of child object “Employment Detail” exists, then create a record with Status = “Ex-Employee”
  • If record exists already then make sure field “Status” Employment Detail is marked as “Ex-Employee”