• Kerri Mesa 18
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I am trying to build out a trigger and trigger handler to update a record related to an Opportunity when the Opportunity is updated. We need to do this without editing the related record (Legal Agreement)

Here is the trigger handler class I am working with:
public class OpportunityTriggerHandler {
    public static void OpportunityTriggerHandler(){       
    	Map <Id,  Opportunity> mapOpportunity = new Map <Id, Opportunity>();
    	List<Legal_Agreements__c> listLA = new List<Legal_Agreements__c>();
    	List<Legal_Agreements__c> LAUpdate = new list <Legal_Agreements__c>();
   
    		listLA = [SELECT Id, Status__c, test__c, Opportunity_Stage__c FROM Legal_Agreements__c WHERE Opportunity__r.Id IN : mapOpportunity.keySet() ];
  			system.debug('Legal Agreement list size ' + listLA.size());
        
    		if(listLA.size() > 0) {
       			 for (Legal_Agreements__c LA : listLA ) {
           			 LA.test__c = LA.Opportunity__r.StageName;
                     LA.test__c = LA.Opportunity_Stage__c;
        		}
    		}
	}
}
And this is the trigger:
trigger OpportunityTrigger on Opportunity (before insert, before update, before delete, after insert, after update, after delete) {
      OpportunityTriggerHandler handler = new OpportunityTriggerHandler();

This is all really rough at this point, but if anyone could guide me, I'd appreciate it.
 
I am trying to build out a trigger and trigger handler to update a record related to an Opportunity when the Opportunity is updated. We need to do this without editing the related record (Legal Agreement)

Here is the trigger handler class I am working with:
public class OpportunityTriggerHandler {
    public static void OpportunityTriggerHandler(){       
    	Map <Id,  Opportunity> mapOpportunity = new Map <Id, Opportunity>();
    	List<Legal_Agreements__c> listLA = new List<Legal_Agreements__c>();
    	List<Legal_Agreements__c> LAUpdate = new list <Legal_Agreements__c>();
   
    		listLA = [SELECT Id, Status__c, test__c, Opportunity_Stage__c FROM Legal_Agreements__c WHERE Opportunity__r.Id IN : mapOpportunity.keySet() ];
  			system.debug('Legal Agreement list size ' + listLA.size());
        
    		if(listLA.size() > 0) {
       			 for (Legal_Agreements__c LA : listLA ) {
           			 LA.test__c = LA.Opportunity__r.StageName;
                     LA.test__c = LA.Opportunity_Stage__c;
        		}
    		}
	}
}
And this is the trigger:
trigger OpportunityTrigger on Opportunity (before insert, before update, before delete, after insert, after update, after delete) {
      OpportunityTriggerHandler handler = new OpportunityTriggerHandler();

This is all really rough at this point, but if anyone could guide me, I'd appreciate it.