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
| //utility class for homework 2 | |
| public with sharing class OpportunityUtility { | |
| //this is static a method that Takes an integer as an argument and returns a list of the top n Opportunities, | |
| //ordered first by amount in descending order, then by Account Name. | |
| //n is the integer that was passed in as an argument | |
| //Include: Opportunity ID, Amount, Account Name, MainCompetitors__c, CloseDate, Stage | |
| public static List<Opportunity> getTopOpportunities(Integer n) { | |
| List<Opportunity> topOpportunities = |
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
| trigger CaseTrigger on Case (before insert, before update, before delete, after insert, after update, after delete, after undelete) { | |
| if(Trigger.isInsert && Trigger.isBefore){ | |
| CaseTriggerHandler.onBeforeInsert(Trigger.new); | |
| } | |
| if(Trigger.isInsert && Trigger.isAfter){ | |
| CaseTriggerHandler.onAfterInsert(Trigger.new); | |
| } | |
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 CaseTriggerHandler { | |
| //Handler Methods | |
| public static void onBeforeInsert(List<Case> newCases) { | |
| //Set default Reason if not provided at case creation | |
| for ( Case c : newCases) { | |
| if (c.Reason == NULL) { | |
| System.debug('---->Case reason is '+c.Reason); | |
| c.Reason = 'Other'; | |
| } | |
| else { |
OlderNewer