Skip to main content

Bulkification

Explore practical guides and implementation patterns for this topic.

Posts

Salesforce Basics

Salesforce Trigger Frameworks: Bulkification & Reentrancy Explained

⚡ 1-Minute Summary: Governor limits act as a transaction budget shared across your code, flows, and packages. Strictly enforce one trigger per object . Keep logic out of the trigger itself and build a bypass switch on day one. Use Queueable as your default asynchronous tool. Avoid writing new @future methods. Module Map: Programmatic Logic & Asynchronous Execution Trigger frameworks (bulkification, reentrancy) Synchronous vs. Asynchronous execution @future / Batch / Queueable / Scheduled Apex Governor limits (the platform's fairness budget) Exception handling & logging Platform Cache Quick Concept: Queues vs. Public Groups Q: What is the core difference between queues and public groups? A: Think of it as ownership versus audience . Queues own records. Unassigned work (like cases, leads, or custom objects) sits in a queue until a member claims it. Public Groups ow...
Read article
Topic Bulkification Governor Limits LimitException Queueable Apex Salesforce Apex Salesforce Architecture SOQL Optimization
Bulkification Governor Limits LimitException Queueable Apex Salesforce Apex Salesforce Architecture SOQL Optimization

Mastering Salesforce Apex Governor Limits: Common Exceptions & Mitigation Strategies

In plain words: Governor Limits are Salesforce's traffic rules for multi-tenant architecture. Because many companies share the same underlying cloud infrastructure, Salesforce enforces strict transaction caps (like memory, queries, and CPU time) so one piece of inefficient code cannot slow down or crash the shared platform. Salesforce executes Apex code in a multi-tenant cloud environment. To guarantee high performance, platform stability, and fair resource sharing, the runtime engine enforces strict per-transaction limits known as Governor Limits . When code exceeds these boundaries, Salesforce throws a fatal runtime LimitException that immediately halts execution. Writing resilient Apex requires a clear understanding of these boundaries and defensive design patterns. 1. Understanding Core Governor Limits Governor limits monitor resources across synchronous and asynchronous transactions. Understanding these thresholds is essential for designing high-thro...
Read article
Topic Apex & Dev
Apex & Dev

How to Fix "Too Many SOQL Queries: 101" in Salesforce: Complete Optimization Guide

In plain words: Think of a SOQL query like ordering items from a warehouse. Placing an order for each item individually ( SOQL in a loop ) takes massive overhead and quickly exhausts your delivery quota. Bulkification means combining everything into a single bulk shopping list ( IN :idSet ) so you make one fast, efficient trip to the database. Salesforce executes database transactions within a multi-tenant cloud environment protected by strict runtime limits. One of the most critical boundaries is the SOQL query limit. When unoptimized code exceeds this allocation, the runtime engine throws an uncatchable System.LimitException: Too many SOQL queries: 101 , immediately halting execution and rolling back uncommitted database work. Designing high-performance Apex requires understanding why queries accumulate and implementing proven bulkification patterns. 1. Understanding the Impact & Governor Limits In Salesforce, governor limits apply to every synchronous a...
Read article
Topic Apex Triggers Best Practices Bulkification Cheatsheet Salesforce Development Trigger Context Variables Trigger Handler Framework
Apex Triggers Best Practices Bulkification Cheatsheet Salesforce Development Trigger Context Variables Trigger Handler Framework

Salesforce Apex Triggers Cheatsheet: Context Variables, Events & Best Practices

In plain words: An Apex Trigger Cheatsheet is a quick-reference guide that summarizes the essential syntax, context variables, and lifecycle events required to automate business logic when records are created, updated, or deleted in Salesforce. It provides clean code snippets and best practices to help developers write fast, bulkified, and scalable backend automation. Apex triggers are powerful server-side blocks of code that execute before or after database events occur on Salesforce objects. Understanding trigger execution events, context variables ( Trigger.new , Trigger.oldMap ), and architectural standards like the "One Trigger Per Object" rule ensures your code runs efficiently and stays well within platform governor limits. 1. Trigger Syntax and Structure An Apex trigger is defined on a specific sObject and listens for one or more database event keywords: trigger AccountTrigger on Account (before insert, before update, after insert, after u...
Read article
Topic Apex & Dev
Apex & Dev

Salesforce Apex Trigger Interview Questions: 3 Real-World Scenarios with Solutions

In plain words: Scenario-based Apex trigger interview questions assess whether a developer understands the Salesforce Order of Execution, how to write bulkified code that never exceeds governor limits, and when to use before vs. after events properly. During technical interviews for Salesforce Developer and Technical Architect roles, interviewers look beyond basic syntax. They present real-world scenarios to evaluate your understanding of bulkification, recursion management, governor limits, and clean trigger architecture. Below are three classic trigger scenarios with production-ready solutions. Scenario 1: Using Before Update for Direct Field Updates Question: Whenever a Case status changes to "Closed", automatically set a custom date/time field ( Closed_Timestamp__c ) to the current timestamp. If reopened, clear the field. How do you implement this efficiently without DML statements? Solution: Use a before update trigger to update fi...
Read article