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 with sharing class MyAccountController { | |
public Double doDivisionOperation1(Integer value1, Integer value2){ | |
Double result; | |
try{ | |
result = value1/value2; | |
}catch(Exception exp){ | |
//HERE WE WILL CATCH EXCEPTION AND LOG INTO Org Exception Log | |
} | |
return result; | |
} |
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 MyAccountTrigger on Account (before insert) { | |
for(Account anAccount : Trigger.new){ | |
AccountHelper accountHelper = new AccountHelper(); | |
if(accountHelper.isSyncEnabled){ | |
//Call Sync Methods | |
}else{ | |
//Do nothing | |
} | |
} | |
} |
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 with sharing class AccountHelper { | |
public AccountHelper accountHelper {get;set;} | |
public Boolean isSyncEnabled {get;set;} | |
public AccountHelper(){ | |
accountHelper = new accountHelper(); | |
Integration__c mdmIntegration = Integration__c.getValues('MDM'); | |
isSyncEnabled = mdmIntegration.isEnabled__c; | |
} | |
} |
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 MyAirportTrigger on Airport__c (after update) { | |
for(Airport__c singleAirport : Trigger.new){ | |
Airport__c oldAirport = Trigger.oldMap.get(singleAirport.Id); | |
if(singleAirport.Country__c != oldAirport.Country__c){ | |
System.Debug('Value changed from ' + oldAirport.Country__c + ' to ' + singleAirport.Country__c); | |
//Send an email | |
} | |
if(singleAirport.Type__c != oldAirport.Type__c){ | |
System.Debug('Value changed from ' + oldAirport.Type__c + ' to ' + singleAirport.Type__c); |
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 with sharing class StopRecursive { | |
private static StopRecursive instance; | |
public Boolean isCalledAlready {get; set;} | |
private StopRecursive(){ | |
isCalledAlready = false; | |
} | |
public static StopRecursive getInstance(){ | |
if(instance == null){ |
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 MyAirportTrigger on Airport__c (after update) { | |
for(Airport__c singleAirport : Trigger.new){ | |
Airport__c oldAirport = Trigger.oldMap.get(singleAirport.Id); | |
if(!StopRecursive.getInstance().isCalledAlready && singleAirport.Country__c != oldAirport.Country__c){ | |
StopRecursive.getInstance().isCalledAlready = true; | |
System.Debug('Value changed from ' + oldAirport.Country__c + ' to ' + singleAirport.Country__c); | |
//Send an email | |
} | |
if(!StopRecursive.getInstance().isCalledAlready && singleAirport.Type__c != oldAirport.Type__c){ |
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 MyAccountTrigger on Account (before insert) { | |
for(Account anAccount : Trigger.new){ | |
AccountHelper myAccountHelper = new AccountHelper(); | |
//Do other operations | |
} | |
} |
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 with sharing class AccountHelper { | |
public Map<String,Schema.SObjectField> mfields {get;set;} | |
public AccountHelper(){ | |
SObjectType accountType = Schema.getGlobalDescribe().get('Account'); | |
mfields = accountType.getDescribe().fields.getMap(); | |
//Do the inspection operation | |
} | |
} |
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 with sharing class AccountHelper { | |
private static AccountHelper self; | |
private Map<String,Schema.SObjectField> mfields {get;set;} | |
private AccountHelper(){ | |
SObjectType accountType = Schema.getGlobalDescribe().get('Account'); | |
mfields = accountType.getDescribe().fields.getMap(); | |
//Do the inspection operation | |
} | |
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 MyAccountTrigger on Account (before insert) { | |
for(Account anAccount : Trigger.new){ | |
AccountHelper myAccountHelper = AccountHelper.getAccountHelper(); | |
//Do other operations | |
} | |
} |