This file contains 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
SELECT | |
TYPEOF What | |
WHEN Account THEN Phone, NumberOfEmployees | |
WHEN Opportunity THEN Amount, CloseDate | |
WHEN Campaign THEN ExpectedRevenue, StartDate | |
ELSE Name | |
END | |
FROM Event |
This file contains 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
The equals method with this signature: | |
public Boolean equals(Object obj) { | |
// Your implementation | |
} | |
Keep in mind the following when implementing the equals method. Assuming x, y, and z are non-null instances of your | |
class, the equals method must be: | |
◊ Reflexive: x.equals(x) | |
◊ Symmetric: x.equals(y) should return true if and only if y.equals(x) returns true | |
◊ Transitive: if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true |
This file contains 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 PairNumbers { | |
Integer x,y; | |
public PairNumbers(Integer a, Integer b) { | |
x=a; | |
y=b; | |
} | |
public Boolean equals(Object obj) { | |
if (obj instanceof PairNumbers) { | |
PairNumbers p = (PairNumbers)obj; | |
return ((x==p.x) && (y==p.y)); |
This file contains 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
Map<PairNumbers, String> m = new Map<PairNumbers, String>(); | |
PairNumbers p1 = new PairNumbers(1,2); | |
PairNumbers p2 = new PairNumbers(3,4); | |
// Duplicate key | |
PairNumbers p3 = new PairNumbers(1,2); | |
m.put(p1, 'first'); | |
153 | |
Developer Console Enhancements Apex Code Enhancements | |
m.put(p2, 'second'); | |
m.put(p3, 'third'); |
This file contains 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 MyDynamicSolution { | |
@future | |
public static void updateOwner(List<ID> objIds, ID newOwnerId) { | |
// Validate input | |
System.assert(objIds != null); | |
System.assert(objIds.size() > 0); | |
System.assert(newOwnerId != null); | |
// Get the sObject token from the first ID | |
// (the List contains IDs of sObjects of the same type). | |
Schema.SObjectType token = objIds[0].getSObjectType(); |
This file contains 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
//TODO: This class will stop allowing trigger to fire-in twice | |
public class ControlledTriggerHelper { | |
// initialize a variable to hold state | |
private static boolean alreadyModified = false; | |
// get the state | |
public static boolean isAlreadyModified() { | |
return alreadyModified; |
This file contains 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 ( Trigger.isAfter ) | |
{ | |
System.debug('in after trigger; alreadyModified: ' + ControlledTriggerHelper.isAlreadyModified()); | |
if (!ControlledTriggerHelper.isAlreadyModified() ) | |
{ | |
ControlledTriggerHelper.setAlreadyModified(); | |
// do something... | |
} | |
} |
This file contains 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 (!RecursiveTriggerHelper.isAlreadyModified() ) | |
{ | |
RecursiveTriggerHelper.setAlreadyModified(); | |
myclass.CheckOwnerChange(oldOpportunity,NewOpportunity); | |
} | |
} |
This file contains 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 OpportunityTrigger on Opportunity (before Update, after Update) | |
{ | |
//Poor Design | |
for (Account acc : Trigger.New) | |
{ | |
//Creating instance of class for each trigger call | |
OpportunityRecordType art = new OpportunityRecordType() | |
...... | |
} | |
This file contains 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 OpportunityTrigger on Opportunity(before Update, after Update) { | |
for (Account acc: Trigger.New) { | |
//Creating instance of class for each trigger call | |
OpportunityRecordType art = OpportunityRecordType.getInstance(); | |
...... | |
} | |
} |