Activity Forums Salesforce® Discussions What is meant by bulkifying trigger?

  • Parul

    August 29, 2018 at 12:56 pm

    Hello Anurag,


    Bulkifying triggers means making sure the trigger can operate when multiple (hundreds) of records are passed in at once.

    When a trigger fires, you get your "list" of objects in (and some other lists/maps).

    Typically when you imagine a trigger firing, you do so thinking that a user has just affected one record, and so this list has one item in it. but in reality, Salesforce could send up to 200 records into the trigger in one list. If you are data loading, or mass updating (or many other things) - this can result in all the items being sent to the trigger in one go.

    So, if you had a trigger, that took the list, and did a for() loop through the items and executed a SOQL query to load some data for each record, because there are govenor limits ( in Salesforce - if the list had more than 100 items in it, the trigger would completely fail - because you made too many SOQL querys, and your data update/insert would be rolled back.

    Making sure these problems don't exist is bulkifying triggers - ie. making sure they can work with multiple (bulk loads) of data.

    There is literally tonnes of blog posts and developer articles on this topic all over the internet: (

    Including an official Salesforce post here:




  • shariq

    September 14, 2018 at 10:30 pm


    To get it more simple bulkifying means that it should work for multiple records.

    The term bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time. When a batch of records initiate Apex, a single instance of that Apex code is executed, but it needs to handle all of the records in that given batch. For example, a trigger could be invoked by an Web Services API call that inserted a batch of records. Or a custom Apex Web Service. So if a batch of records invokes the the same Apex code, all of those records need to be processed as a bulk, in order to write scalable code and avoid hitting governor limits.

    for example :-

    trigger accountTestTrggr on Account (before insert, before update) {

    List<String> accountNames = new List<String>{};

    //Loop through all records in the collection
    for(Account a:{
    //Concatenate the Name and billingState into the Description field
    a.Description = a.Name + ':' + a.BillingState


    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Free 5 Day Salesforce Challenge!

Video in

To access the signup form head over to TalentStacker Podcast Salesforce Episode: Do you already have a job as a Salesforce Professional and…