Skip to content

Instantly share code, notes, and snippets.

View suddeb's full-sized avatar

Sudipta Deb suddeb

View GitHub Profile
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;
}
@suddeb
suddeb / MyAccountTrigger
Created May 29, 2015 07:14
MyAccountTrigger
trigger MyAccountTrigger on Account (before insert) {
for(Account anAccount : Trigger.new){
AccountHelper accountHelper = new AccountHelper();
if(accountHelper.isSyncEnabled){
//Call Sync Methods
}else{
//Do nothing
}
}
}
@suddeb
suddeb / AccountHelper
Created May 29, 2015 07:15
AccountHelper
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;
}
}
@suddeb
suddeb / MyAirportTrigger
Created June 4, 2015 15:11
MyAirportTrigger
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);
@suddeb
suddeb / StopRecursive
Created June 4, 2015 16:17
StopRecursive
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){
@suddeb
suddeb / MyAirportTrigger
Created June 4, 2015 16:18
MyAirportTrigger
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){
@suddeb
suddeb / MyAccountTrigger
Created June 5, 2015 06:15
MyAccountTrigger
trigger MyAccountTrigger on Account (before insert) {
for(Account anAccount : Trigger.new){
AccountHelper myAccountHelper = new AccountHelper();
//Do other operations
}
}
@suddeb
suddeb / AccountHelper
Created June 5, 2015 06:15
AccountHelper
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
}
}
@suddeb
suddeb / AccountHelper
Created June 5, 2015 06:20
AccountHelper
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
}
@suddeb
suddeb / MyAccountTrigger
Created June 5, 2015 06:21
MyAccountTrigger
trigger MyAccountTrigger on Account (before insert) {
for(Account anAccount : Trigger.new){
AccountHelper myAccountHelper = AccountHelper.getAccountHelper();
//Do other operations
}
}