Created
July 31, 2015 19:36
-
-
Save pcave/7b9bb359305e237c0e32 to your computer and use it in GitHub Desktop.
Ugly Apex
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 ActionsTakenTriggerHandler on jrsbd__sb_Actions_Taken__c (after insert) { | |
Map<Id, Integer> actionsTaken = new Map<Id, Integer>(); | |
Map<Id, Integer> petitionsSigned = new Map<Id, Integer>(); | |
Map<Id, Integer> actionsLast30Days = new Map<Id, Integer>(); | |
// Figure out how many actions taken and petitions signatures are going to be added to each Contact. | |
for (jrsbd__sb_Actions_Taken__c actionTaken: Trigger.new) { | |
if (actionTaken.jrsbd__Action_Type__c == 'Petition') { | |
if (petitionsSigned.containsKey(actionTaken.jrsbd__Contact__c)) { | |
petitionsSigned.put(actionTaken.jrsbd__Contact__c, petitionsSigned.get(actionTaken.jrsbd__Contact__c) + 1); | |
} | |
else { | |
petitionsSigned.put(actionTaken.jrsbd__Contact__c, 1); | |
} | |
} | |
else if (actionTaken.jrsbd__Action_Type__c == 'Message Action') { | |
if (actionsTaken.containsKey(actionTaken.jrsbd__Contact__c)) { | |
actionsTaken.put(actionTaken.jrsbd__Contact__c, actionsTaken.get(actionTaken.jrsbd__Contact__c) + 1); | |
} | |
else { | |
actionsTaken.put(actionTaken.jrsbd__Contact__c, 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment