Posts

Showing posts from December, 2017

Slaesforce Triggers

Image
What is Apex Triggers ? A Trigger is Apex code that executes before or after the following types of operations: insert update delete merge upsert undelete Types of Apex Triggers Before Triggers: Before triggers can be used to update or validate record values before they are saved to the database. After Triggers: After triggers can be used to access field values that are set by the database (such as a record's Id or last Updated field), and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue. Example : before insert, after insert, before update, after update, before delete, after delete Syntax of Trigger Important Points- Bulkify your Code : Use Looping through Trigger’s collections variables instead of process through particular indexing. All triggers are bulk triggers by default, and can process multiple records at a time. Bulk triggers can handle both single record updates and bulk

Batch Apex

What is batch class? Batch class is just similar to Apex class except that batch class includes the Salesforce provide interface “Database.Batchable”. Why we use batch class? When we want to perform DML operations for bulk records or hit the web service then batch class comes in the picture. Database.Batchable interface contains three method. Start Execute Finish Start Method       global Database.QueryLocater start(Database.BatchableContext bc) {} Use this method to get the records from database or object to be passed to “Execute” method. This method returns Database.QueryLocater object that contains the records. Query fired in the start method will return maximum 5,000,0000 records in a transaction. Execute Method            global void execute(Database.BatchableContext bc , List  scope) {} This method is used for do all the processing for data. This method takes two arguments. A reference of Database.BatchableContext object. A list of sObjec