Thursday, November 8, 2018

Best Practices for writing Apex Triggers in Salesforce.com

Best Practices for writing Apex Triggers

1) Follow only one trigger for each object.

2) Logicless Trigger, which means create a helper method to keep all logic and finally call that helper class and method in the trigger.

3) Bulkify helper class or trigger to avoid governor limits.

4) Avoid using SOQL and DML within for loop.

5) Use collections like list, set and map to store on large set of data.

6) Use streamline queries and efficient for loop to process large set of data.

7) Use addError() method to show error message upon validation.

8) Use try and catch block to handle exception and throw error messages.










No comments:

Post a Comment

Validation in flow input text field in sfdc: Maximum 255 characters limit

The input text field validate in sfdc flow behaves opposite of the generic sfdc validation rule.  Here the validation formula is evaluating ...