Apex Triggers - 16 (TCS Interview Question)
1. Scenario Overview This automation addresses a TCS Interview Question involving roll-up style calculation across parent-child relationships. The Account object contains a custom text field named Max_OPP__c . The requirement mandates that this field must always display the Name of the related Opportunity record that has the highest Amount . Because this value can change across any data mutation phase, the trigger handles a full suite of events ( after insert , after update , after delete , and after undelete ) to safely re-calculate metrics on parent Accounts. or Update the Parent Account field with the Opportunity Name that has the Highest Amount. 2. Apex Handler Class java public class OpportunityTriggerHandler { public static void updateMaxOpportunityName ( List < Opportunity > newOpps , Map < Id , Opportunity > oldOppMap ) { Set < Id > accountIds = new Set < Id >(); // Phase 1: Track all impacted Account IDs acros...