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 override void afterUpdate() { | |
this.bypass('AccountTriggerHandler'); //yeah, if you could just ignore that accountTrigger, *that'd be great* | |
acc.Name = 'No Trigger'; // wait! where'd acc come from? … just keeping you on your toes. | |
update acc; // won't invoke the AccountTriggerHandler | |
this.clearBypass('AccountTriggerHandler'); // actually, yeah. need you run that accountTrigger. | |
acc.Name = 'With Trigger'; | |
update acc; // will invoke the AccountTriggerHandler |
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 ContactTriggerLogic Extends TriggerHandler { | |
Public ContactTriggerLogic() { | |
this.setMaxLoopCount(1); | |
} | |
} |
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 ContactTriggerLogic Extends TriggerHandler { | |
Map<Id,Account> newMap; | |
Public ContactTriggerLogic() { | |
this.newMap = (Map<Id, Account>) Trigger.newMap; | |
} | |
Public Contact addSnark(Contact c){ | |
if(!c.lastName.contains(' is awesome!')){ | |
c.lastName = c.lastName + ' is awesome!'; |
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 AccountTriggerLogic Extends TriggerHandler{ | |
//... | |
} |
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 DescriptiveTriggerNameHere on ObjectNameHere (execution,context,list){ | |
new YourTriggerLogicClassNameHere().run(); | |
} |
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
IF( | |
ISBLANK(Line_Item__c), | |
CASE( | |
TEXT(Platform_Line_Item__r.Fee_Structure__c), | |
"Media Spend", | |
IF( | |
End_date__c > TODAY(), | |
Monthly_Projected_Spend__c, | |
Monthly_Actual_Spend__c | |
), |
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
//In a class far far away... | |
@future | |
global static void RunMockCalloutForTest(String accountId){ | |
TestRestClient trc = new TestRestClient(); | |
id aId; | |
try { | |
aId = (Id) accountId; | |
} catch (Exception e) { | |
throw new exception('Failed to cast given accountId into an actual id, Send me a valid id or else.'); | |
} |
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
//In your test… | |
@isTest | |
static void test_method_one() { | |
//If you're not using SmartFactory, you're doing it way too hard. (and wrong) | |
Account account = (Account)SmartFactory.createSObject('Account'); | |
insert account; | |
Test.startTest(); | |
MyFarawayClass.RunMockCalloutForTest(account.id); | |
Test.StopTest(); | |
} |
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
List<Contact> PunishIt = new List<Contact>(); | |
for(Integer i = 0; i < 1000; i++) { | |
PunishIt.add(Conctact c = new contact(fill in missing = stuff here)); | |
} | |
Insert PunishIt; | |
Delete PunishIt; |
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
global with sharing class GuidUtil { | |
private static String kHexChars = '0123456789abcdef'; | |
global static String NewGuid() { | |
String returnValue = ''; | |
Integer nextByte = 0; | |
for (Integer i=0; i<16; i++) { | |
if (i==4 || i==6 || i==8 || i==10) | |
returnValue += '-'; | |
nextByte = (Math.round(Math.random() * 255)-128) & 255; |