When preparing for Salesforce Developer interviews in 2025, one thing is clear: interviewers donโt want definitions, they want real-world problem-solving.
That means you must be ready to solve scenarios:
- Handling recursion in triggers
- Designing bulk-safe automation
- Optimizing SOQL queries
- Choosing between Batch, Queueable, or Scheduled Apex
- Migrating from Workflow/Process Builder to Flow
This blog covers 15 common Salesforce interview scenarios with descriptive answers and Apex code that will help you shine in interviews.
1. Trigger Recursion โ Prevent Double Execution
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.
2. Bulk-Safe Trigger with Handler Pattern
Scenario: Design a trigger on Opportunity that handles insert/update without hitting governor limits.
Answer (descriptive):
Always make triggers bulk-safe. That means:
- No SOQL/DML inside loops
- Use Sets and Maps
- Delegate logic to a handler class
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.
3. Partial Success with Database.update
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.
4. Mixed DML Error
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.
5. Nightly Processing with Batch + Schedule
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.
6. SOQL Optimization
Scenario: Fetch 10,000 Opportunities with related Accounts without hitting limits.
Answer: Use parent-child queries and never put SOQL inside loops.
7. HTTP Callout with Resilience
Scenario: Call an external REST API with retries and error handling.
Answer: Use Named Credentials, set timeouts, and retry on 5xx errors.
8. Queueable Chaining
Scenario: You need to run parse โ enrich โ notify jobs after a file upload.
Answer: Use Queueable chaining where one job enqueues the next.
9. Enforcing Security in Apex
Scenario: Ensure CRUD/FLS rules are respected in Apex.
Answer: Use with sharing
+ Security.stripInaccessible()
.
10. LWC with Pagination
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.
11. Using LDS instead of Apex
Scenario: Update a Contact without writing Apex.
Answer: Use Lightning Data Service (updateRecord
) from lightning/uiRecordApi
.
12. Approval Process in Apex
Scenario: Auto-submit Opportunities > 50k for approval.
Answer: Use Approval.ProcessSubmitRequest
inside Apex.
13. Error Handling
Scenario: Log unexpected errors without breaking user flow.
Answer: Catch exceptions, publish Platform Events, and show user-friendly messages.
14. Mocking Callouts in Tests
Scenario: Write a test for an Apex callout without hitting the real API.
Answer: Implement HttpCalloutMock
in your test class.
15. Savepoints & Rollback
Scenario: Insert Account + Contacts, but keep Account if Contacts fail.
Answer: Use Savepoint
+ Database.rollback()
.
๐ฏ Final Takeaway
๐ 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.
๐ More Resources for You
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