Created
March 11, 2014 19:31
-
-
Save dancinllama/9493289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OpportunityTriggerHandler extends TriggerHandler { | |
private Map<Id, Opportunity> newOpportunityMap = new Map<Id, Opportunity>(); | |
private Map<Id, Opportunity> oldOpportunityMap = new Map<Id, Opportunity>(); | |
private List<Opportunity> triggerNew = new List<Opportunity>(); | |
private List<Opportunity> triggerOld = new List<Opportunity>(); | |
public OpportunityTriggerHandler() { | |
this.triggerNew = (List<Opportunity>) Trigger.new; | |
this.triggerOld = (List<Opportunity>) Trigger.old; | |
} | |
Public Override void afterUpdate() { | |
UpdateOppTeam(); | |
} | |
Private void UpdateOppTeam(){ | |
//Iterate through opportunities, checking whether since this trigger has run, if the opportunity was closed. e.g. if(!Trigger.oldMap.get(newOppty.Id).IsClosed && newOppty.IsClosed) | |
//For any closed oppties, add the Opportunity Ids to a Set<Id> | |
//Re-Query opportunities to look for "Manager" role in Owner's role. e.g. [Select Id from Oppty Where OwnerId in :myClosedOpptiesIds and Owner.Role='Manager']; | |
//Loop through that query, and construct your list of OpportunityTeamMember records. | |
//Outside of that loop (at the end of your trigger method, insert the list of opportunity team members. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment