
WELCOME TO SALESFORCEDEMYSTIFIED
Naturally Curious
SalesforceDemystified endeavors to simplify the concepts in Salesforce. And I love having the opportunity to share my passions and thoughts with my loyal readers. Read on, and enjoy.
Custom settings for storing app configuration
Custom settings can be used for storing app configuration data that is cached instead of storing in the database. This helps in quickly...
Use of static variables in Apex Triggers and Unit Testing
Eg: Trigger on a contact to send email when its owner changes. It uses Apex class to handle the logic. trigger ContactOwnerChangeTrigger...
InnerClass, Interface, Virtual and Abstract class
public with sharing class OuterClass { //Static final variable - outer class only public static final Integer MY_INT; ...
General Use cases
A case is entered and submitted on an external web form. It gets created on Salesforce. On Salesforce there should be a mechanism to find...
Using List of Lists
List<List<Integer>> l = new List<List<Integer>>(); List<Integer> k = new List<Integer>(); for(Integer ctr=0; ctr<3; ctr++ ){ for(Integer...
Entry point for Synchronous and Asynchronous methods
public with sharing class futureexperiment { private static Boolean futuresent = false; public static void test2() { //entry point for...
External events that triggers Apex execution
DML operation that triggers Apex Trigger Scheduled Apex that executes at the scheduled time Batch Apex method that called regularly...
List & Map
//Account a = new Account(name='Account14', Type='Prospect'); //Account b = new Account(name='Account15', Type='Prospect'); /* //defining...
Custom Iterator to traverse through collections
An iterator traverses through every item in a collection. Use case - where we need some complex logic to build scope of the batch or for...
DML operations: Complete or none option or Partial option
Apex offers two ways to perform DML operations: using DML statements or Database class methods. DML statements are more straightforward...
To provide sObject details and their fields
/* //to return a map of all sObject names(Keys) to sObject tokens(values) Map<String, Schema.SObjectType> globalDescribes =...
Use Apex Scheduler for regular maintenance tasks
To invoke Apex classes to run at specific times, first implement the Schedulable interface for the class. Then, schedule an instance of...
Batch Apex for processing huge number of records
It breaks down a huge batch into manageable chunks. Real life use - a data cleansing operation that goes through all Accounts and...
Store related parent record to a Map in Trigger
use case = to store the last opportunity to the account trigger oppTrg on Opportunity(after insert){ //to map the parent i.e account to...
Usage of before triggers
Before triggers are used to update or validate record values before they’re saved to the database. Use Case: Every time an account is...
To share a record using Apex
Use case: suppose that you are building a recruiting application and have an object called Job. You want to validate that the recruiter...
Use of transient variable
use case - everytime a page is requested the datetime variable is updated. Solution: declare the datetime variable as transient. public...
When to use Trigger.oldMap & Trigger.newMap?
use case: If the opportunity has been changed to 'Closed Won' then check the checkbox. Solution: Trigger.new returns a list, which are...
Trigger should not contain logic, it should delegate to handler class
Eg: trigger trgOp on Opportunity (before delete, before insert, before update, after delete, after insert, after update){ OpTrgHandler...


