Activity Forums Salesforce® Discussions What is a good practice for a Developer to follow while writing a Trigger in Salesforce?

  • Anjali

    Member
    February 3, 2020 at 1:03 pm
    • There should only be one trigger for each object.
    • Avoid complex logic in triggers. To simplify testing and reuse, triggers should delegate to Apex classes which contain the actual execution logic.
    • Bulkify any "helper" classes and/or methods.
    • Triggers should be "bulkified" and be able to process up to 200 records for each call.
    • Execute DML statements using collections instead of individual records per DML statement.
    • Use Collections in SOQL "WHERE" clauses to retrieve all records back in a single query
    • Use a consistent naming convention including the object name.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos