Scenario: A before-update trigger on Account updates a field and keeps firing recursively.
Answer (descriptive):
Recursion happens when the trigger modifies records that cause it to fire again. To prevent this, use a static Boolean variable in a helper class. This ensures the trigger runs only once per transaction.
Code:
public class AccountTriggerGuard {
public static Boolean hasRun = false;
}
trigger AccountBeforeUpdate on Account (before update) {
if (AccountTriggerGuard.hasRun) return;
AccountTriggerGuard.hasRun = true;
for (Account acc : Trigger.new) {
if (acc.Industry == null) acc.Industry = 'Unknown';
}
}
π This is a must-know in interviews because trigger recursion is a very common real-world issue.
Scenario: Design a trigger on Opportunity that handles insert/update without hitting governor limits.
Answer (descriptive):
Always make triggers bulk-safe. That means:
Code:
trigger OpportunityTrigger on Opportunity (after insert, after update) {
OpportunityHandler.run(Trigger.isInsert, Trigger.isUpdate, Trigger.newMap);
}
public class OpportunityHandler {
public static void run(Boolean isInsert, Boolean isUpdate, Map<Id, Opportunity> newMap) {
Set<Id> acctIds = new Set<Id>();
for (Opportunity opp : newMap.values())
if (opp.AccountId != null) acctIds.add(opp.AccountId);
Map<Id, Account> accts = new Map<Id, Account>(
[SELECT Id, NumberOfEmployees FROM Account WHERE Id IN :acctIds]
);
List<Opportunity> toUpdate = new List<Opportunity>();
for (Opportunity opp : newMap.values()) {
Account a = accts.get(opp.AccountId);
if (a != null && a.NumberOfEmployees > 1000) {
opp.StageName = 'High Priority';
toUpdate.add(opp);
}
}
if (!toUpdate.isEmpty()) update toUpdate;
}
}
π This demonstrates real-world Apex best practices that every interviewer looks for.
Scenario: You need to update thousands of Contacts, but some may fail validation.
Answer: Use Database.update(list, false)
which allows partial success and returns errors for failed records. This shows you understand error handling in bulk operations.
Scenario: Updating a User and Account in the same transaction throws MIXED_DML_OPERATION.
Answer: Move one operation to an async context (@future
or Queueable
). This shows your knowledge of governor limits + transaction boundaries.
Scenario: A job should run daily at 2 AM to update 50,000+ Cases.
Answer: Use Batch Apex for large data + Scheduled Apex with CRON to run nightly. This is a classic interview scenario.
Scenario: Fetch 10,000 Opportunities with related Accounts without hitting limits.
Answer: Use parent-child queries and never put SOQL inside loops.
Scenario: Call an external REST API with retries and error handling.
Answer: Use Named Credentials, set timeouts, and retry on 5xx errors.
Scenario: You need to run parse β enrich β notify jobs after a file upload.
Answer: Use Queueable chaining where one job enqueues the next.
Scenario: Ensure CRUD/FLS rules are respected in Apex.
Answer: Use with sharing
+ Security.stripInaccessible()
.
Scenario: Build a Lightning Web Component with server-side pagination.
Answer: Expose an @AuraEnabled method in Apex that uses LIMIT
+ OFFSET
. Call imperatively from LWC.
Scenario: Update a Contact without writing Apex.
Answer: Use Lightning Data Service (updateRecord
) from lightning/uiRecordApi
.
Scenario: Auto-submit Opportunities > 50k for approval.
Answer: Use Approval.ProcessSubmitRequest
inside Apex.
Scenario: Log unexpected errors without breaking user flow.
Answer: Catch exceptions, publish Platform Events, and show user-friendly messages.
Scenario: Write a test for an Apex callout without hitting the real API.
Answer: Implement HttpCalloutMock
in your test class.
Scenario: Insert Account + Contacts, but keep Account if Contacts fail.
Answer: Use Savepoint
+ Database.rollback()
.
π Salesforce interviews in 2025 are all about scenarios + real solutions.
π Practice triggers, batch jobs, async Apex, Flows, and LWC communication patterns.
π Always write bulk-safe, secure, and testable code β thatβs what sets candidates apart.
Here are some resources to go deeper:
π 100 Scenarios (1β4 YOE)
π 100 Scenarios (4β8 YOE)
π LWC Q&A (Real Answers Explained)
π 600+ Qs from Recruiter Calls
π TCS, Infosys, EY Interview Qs
π Salesforce Project β Hindi + English