-

Comparing Aggregate Query vs Map in Salesforce Apex
Introduction In Salesforce, roll-up triggers are a common technique to summarize child records’ data into parent records. Whether you’re counting related records or adding up specific field values, your approach choice greatly affects the solution’s efficiency. It also impacts maintainability. Two popular strategies are Aggregate Query and Map-Based Manual Aggregation. You can refer our previous…
-

How to Prevent Recursion in Apex Triggers in salesforce: Best Practices Explained
Apex triggers can recurse when a trigger causes itself to execute repeatedly. This recursion potentially leads to infinite loops and hits Salesforce governor limits. This often happens when a trigger performs DML operations that invoke the same trigger again. To maintain system stability and data integrity, it’s crucial to implement strategies that prevent such recursive…
-

Learning Apex Triggers (Part 3) – Comprehensive Guide to Before and After Trigger Scenarios
In continuation of our previous post Learning Apex Triggers (Part1), this guide will provide use cases. It will also provide examples for each trigger event. It is part of the “Learning Apex Triggers” series. Salesforce triggers are small pieces of code that run automatically when records change in Salesforce. They let you add custom logic…
-

Streamlining Apex Triggers with a Modular Apex Trigger Framework
Managing complex business logic in Salesforce can quickly become unwieldy, especially when dealing with multiple triggers and varied business requirements. We implemented a robust Apex Trigger Framework. This uses the Trigger Handler Pattern approach. It ensures scalability. It also ensures maintainability and reusability. Our Apex Trigger Framework separates concerns by organizing logic into a trigger,…
-
How to Improve Dynamic SOQL Queries in Salesforce Apex with Database.queryWithBinds() Salesforce Apex Spring ’23 release
If you’re working with Salesforce’s Apex programming language, you may need to write a query to search for specific records in the Salesforce database. In some cases, you may not know the specific values to search for at the time you write the query. In these cases, you can build a dynamic SOQL query…
-

Restrict specific characters in all input Text fields using apex trigger in Salesforce
Introduction: Sometimes you may get a requirement to restrict specific characters in input fields. In such cases, Apex triggers come in handy. Salesforce is a powerful customer relationship management (CRM) tool that can store a vast amount of sensitive information. As a best practice, it’s essential to ensure that data is protected from malicious attacks…
-

Restrict Standard Picklist values within the defined set in Salesforce using apex triggers
Sample Code: Here is the sample code for the trigger. It restricts Standard Picklist values, such as Opportunity Type and Lead Source fields, in the Opportunity object. This is done using an Apex Trigger called “ValidatePicklistValues”. For more helpful articles please visit – https://thesalesforcedev.in/
-

Learning Apex Triggers (Part 2) – Trigger Handler Pattern Implementation
Introduction: Welcome to the continuation of our previous post Learning Apex Triggers (Part1). Let’s explore the trigger handler pattern implementation. We’ll also discuss some best practices for triggers in the code in this post. Implementing a Trigger Handler Pattern in Salesforce is a widely recognized best practice. It enhances the organization and maintainability of your…
-

Learning Apex Triggers (Part 1) – Understanding Trigger Basics
Introduction: Welcome to our first blog post, in “Learning Apex Triggers” series. In this blog post, we will be learning about basics of apex triggers, their events and features. Trigger Best Practices Trigger Operation type and context variables availability Before Insert: After Insert: Before Update: After Update: Before Delete: After Delete: After Undelete: For more…
-

Roll Up Summary Trigger To Update Total Contact On Account In Salesforce
Introduction: In this blog post, we will see an example on how to roll up child values on a parent record. This applies to both master-detail and lookup relationships. In this example. we will demonstrate updating total contacts count on Account. This will be done using roll up summary apex trigger and aggregate query. The…
