Showing posts from May, 2017

Apex Coding Best practices- What to do what not to do

Salesforce Apex code Best Practice part-1
1. Constants should be all capital letters and define with static final. Don't:  public String Account_TYPE = 'Personal'; Do: public static final String ACCOUNT_TYPE = 'Personal'; 2. Variable names and Method names should be camel case and use proper naming convention.(first lettere small)
String AccountName = 'Nagarjun'; Do:
String accountName = 'Nagarjun'; 3. Remove SOQL Queries and DML statements in for loops.
List<String> accountIds = new List <String> {'0013600000YWwxE','0013600000919el'};
List<Account> AccountsList;
for(String accountId: accountIds){
Account validAccount = [Select id, Name from Account Where id=:accountId];
} Do:
List<String> accountIds = new List <String> {'0013600000YWwxE','0013600000919el'};
List<Account> AccountsList = [Select id, Name from Account Where id IN:accoun…

Useful handy commands for salesforce developers

Salesforce Developer Console handy Commands
1. Delete the records in object from Developer console  Delete[Select id from Account limit 10000]; 2. Abort the Batch jobs from Developer console
for(AsyncApexJob job:[SELECT Id, Status FROM AsyncApexJob WHERE Status IN ('holding','Queued','Preparing')])
System.abortJob(;  3. Delete all Scheduled jobs from salesforce developer console anonymous window
for(CronTrigger CT: [Select Id from CronTrigger Limit 100])
System.abortjob(CT.Id);   4.