Activity Forums Salesforce® Discussions Why we avoid DML query in "before" trigger in Salesforce?

  • Avnish Yadav

    July 5, 2018 at 5:39 am

    Hello Chanchal,

    In Before trigger, the records are not commited in database so we can skip the DML as whatever value we give to records will naturally assigned to database.


  • madhulika shah

    September 10, 2018 at 1:11 pm

    Hi Chanchal,

    Before triggers are used to update or validate record values before they’re saved to the database. Avoid SOQL queries and DML inside for loops so that governor limit cannot be hit.


  • shariq

    September 22, 2018 at 3:23 am


    In Before Triggers, actions are being performed before you commit the record to the database. This is where you usually do validations or updates to the same object. You can skip the DML operations here as whatever values you give in your code is automatically assigned to that record.

    Hope this helps.

  • William

    November 26, 2018 at 4:28 am

    Before triggers are used to perform the logic on the same object and it triggers fired before the data saved into the database. For DML operation it required to commit with data base. So, we cannot use the DML operation on these triggers.

    As per Order of execution before trigger fire and then after trigger fire.

    Before insert event

    Data committed to database

    After insert event

Log In to reply.

Popular Salesforce Blogs