0% found this document useful (0 votes)
9 views25 pages

Salesforce Debugging Interview Questions

The document provides a comprehensive list of Salesforce debugging interview questions and answers, covering various topics such as Apex, LWC, Flow, SOQL, and integrations. It includes techniques for debugging, explanations of key concepts like Debug Logs and Trace Flags, and common errors with their solutions. Each section offers practical examples and best practices for effectively troubleshooting issues in Salesforce development.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

Salesforce Debugging Interview Questions

The document provides a comprehensive list of Salesforce debugging interview questions and answers, covering various topics such as Apex, LWC, Flow, SOQL, and integrations. It includes techniques for debugging, explanations of key concepts like Debug Logs and Trace Flags, and common errors with their solutions. Each section offers practical examples and best practices for effectively troubleshooting issues in Salesforce development.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Salesforce Debugging Interview Questions & Answers

Below are Salesforce debugging interview questions with answers, mainly for Apex, LWC,
Flow, SOQL, integrations, and production issue debugging.

1. What are the common ways to debug in Salesforce?


Answer:
In Salesforce, we can debug using:
1. Debug Logs
2. Developer Console
3. Apex Replay Debugger
4. [Link]()
5. Trace Flags
6. Log Levels
7. Flow Debug Tool
8. Browser Console for LWC
9. Network tab for API/LWC calls
10. Exception Emails
11. Apex Jobs / Async Apex monitoring
12. Setup Audit Trail
13. Field History Tracking
14. Event Monitoring, if enabled
For Apex issues, I usually start with Debug Logs and check exception stack trace, SOQL
queries, DML operations, and variable values.

2. What is a Debug Log in Salesforce?


Answer:
A Debug Log records what happens during a Salesforce transaction. It captures Apex
execution, SOQL queries, DML operations, validation rules, workflow, flow execution,
callouts, and exceptions.
We can enable debug logs from:
Setup -> Debug Logs -> New Trace Flag
We select the user, start time, expiration time, and log level.

3. What is a Trace Flag?


Answer:
A Trace Flag is used to enable logging for a specific user, Apex class, trigger, or automated
process.
Example:
If a user is facing an error while saving a record, we create a trace flag for that user and
reproduce the issue. Then we check the generated debug log.

4. What are Log Levels in Salesforce?


Answer:
Log levels control how much detail is captured in the debug log.
Common log categories are:

Category Purpose
Apex Code Apex class and trigger execution
Apex Profiling Method execution time
Database SOQL, SOSL, DML
Validation Validation rules
Workflow Workflow, process, flow actions
Callout HTTP callouts
System System methods
Visualforce VF page execution

Common levels are:


NONE, ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST

Usually for debugging Apex, we set Apex Code = DEBUG and Database = INFO or FINE.

5. What is [Link]()?
Answer:
[Link]() is used to print variable values or custom messages in debug logs.

Example:
Account acc = [SELECT Id, Name FROM Account LIMIT 1];
[Link]('Account Name is: ' + [Link]);

We use it to verify values during code execution.


Better practice:
[Link]([Link], 'Account record: ' + acc);
6. What is the difference between debug log and [Link]()?
Answer:
A debug log is the complete transaction log generated by Salesforce.
[Link]() is a statement we add in Apex code to print specific values inside that log.

So, [Link]() output appears inside the debug log.

7. How do you debug an Apex trigger?


Answer:
I follow these steps:
1. Enable debug log for the user.
2. Reproduce the issue.
3. Open the generated debug log.
4. Search for:
– EXCEPTION_THROWN
– FATAL_ERROR
– USER_DEBUG
– Trigger name
– SOQL/DML statements
5. Check trigger context like before insert, after update, etc.
6. Verify values in [Link], [Link], and maps.
7. Check if any validation rule, flow, or process builder is also firing.
Example debug:
trigger AccountTrigger on Account (before update) {
for(Account acc : [Link]) {
[Link]('New Account Name: ' + [Link]);
[Link]('Old Account Name: ' + [Link]([Link]).Name);
}
}

8. How do you debug a trigger recursion issue?


Answer:
Trigger recursion happens when the same trigger keeps firing again due to DML inside
trigger logic.
Example:
trigger AccountTrigger on Account (after update) {
update [Link];
}

This causes recursion because update inside after update again fires the trigger.
Solution: use a static Boolean variable.
public class TriggerHandler {
public static Boolean isFirstRun = true;
}

trigger AccountTrigger on Account (after update) {


if([Link]) {
[Link] = false;

List<Account> accountsToUpdate = new List<Account>();

for(Account acc : [Link]) {


[Link](new Account(
Id = [Link],
Description = 'Updated from trigger'
));
}

update accountsToUpdate;
}
}

9. How do you debug a governor limit issue?


Answer:
First, I check the debug log for governor limit errors like:
Too many SOQL queries: 101
Too many DML statements: 151
CPU time limit exceeded
Heap size too large
Too many future calls

Then I check:
1. SOQL inside loops
2. DML inside loops
3. Nested loops
4. Recursive trigger calls
5. Heavy flows or process builders
6. Unnecessary queries
7. Large data volume processing
Bad code:
for(Account acc : accounts) {
Contact con = [SELECT Id FROM Contact WHERE AccountId = :[Link] LIMIT 1];
}

Correct code:
Set<Id> accountIds = new Set<Id>();

for(Account acc : accounts) {


[Link]([Link]);
}

List<Contact> contacts = [
SELECT Id, AccountId
FROM Contact
WHERE AccountId IN :accountIds
];

10. What is the error “Too many SOQL queries: 101”?


Answer:
Salesforce allows only 100 SOQL queries per synchronous transaction. This error usually
happens when SOQL is written inside a loop or multiple automation tools are running in
the same transaction.
Example wrong code:
for(Contact con : contactList) {
Account acc = [SELECT Id, Name FROM Account WHERE Id = :[Link]];
}

Correct approach is to bulkify the code and query outside the loop.

11. How do you debug “Attempt to de-reference a null object”?


Answer:
This error means we are trying to access a field or method on a null object.
Example:
Account acc;
[Link]([Link]);

Here acc is null.


Correct code:
if(acc != null) {
[Link]([Link]);
}

In real scenarios, I check whether the SOQL query returned data, whether lookup fields are
blank, or whether map keys exist before accessing values.
Example:
if([Link]([Link])) {
Account acc = [Link]([Link]);
}

12. How do you debug “List has no rows for assignment to SObject”?
Answer:
This happens when SOQL is directly assigned to a single SObject and no record is returned.
Wrong:
Account acc = [SELECT Id FROM Account WHERE Name = 'Test' LIMIT 1];

If no Account exists, it throws an exception.


Correct:
List<Account> accList = [
SELECT Id
FROM Account
WHERE Name = 'Test'
LIMIT 1
];

if(![Link]()) {
Account acc = accList[0];
}

13. How do you debug DML exceptions?


Answer:
DML exceptions happen during insert, update, delete, or upsert.
Example errors:
FIELD_CUSTOM_VALIDATION_EXCEPTION
REQUIRED_FIELD_MISSING
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
DUPLICATE_VALUE
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

I debug by checking:
1. Required fields
2. Validation rules
3. Record type access
4. Field-level security
5. Lookup/master-detail access
6. Duplicate rules
7. Trigger or Flow errors
8. User profile permissions
Example:
try {
insert accList;
} catch(DmlException e) {
[Link]('DML Error: ' + [Link]());
}

For partial success:


[Link][] results = [Link](accList, false);

for([Link] sr : results) {
if(![Link]()) {
for([Link] err : [Link]()) {
[Link]('Error: ' + [Link]());
}
}
}

14. What is the difference between insert and [Link]?


Answer:
insert is an all-or-none DML operation. If one record fails, all records fail.
insert accountList;

[Link]() allows partial success when we pass false.


[Link](accountList, false);

This is very useful for debugging because we can identify which specific records failed and
why.

15. How do you debug Flow issues?


Answer:
For Flow debugging, I use:
1. Debug button inside Flow Builder
2. Debug Logs
3. Flow error emails
4. Paused and Failed Flow Interviews
5. Check input variables
6. Check decision outcomes
7. Check Get Records result
8. Check field values before Update/Create Records
9. Check user permissions
Common Flow errors:
FIELD_CUSTOM_VALIDATION_EXCEPTION
REQUIRED_FIELD_MISSING
CANNOT_EXECUTE_FLOW_TRIGGER
INSUFFICIENT_ACCESS

I also check whether the Flow is running in user context or system context.

16. How do you debug Record-Triggered Flow?


Answer:
I check:
1. Object and trigger condition
2. Entry criteria
3. Before-save or after-save flow
4. Whether record actually meets the criteria
5. Order of execution
6. Field updates done by other automation
7. Debug logs for user
8. Failed Flow Interviews
For record-triggered flows, debug logs are very useful because they show flow execution
paths.

17. How do you debug LWC issues?


Answer:
For LWC, I use:
1. Browser console
2. [Link]()
3. Network tab
4. Salesforce debug logs for Apex
5. Check Apex response
6. Check JavaScript errors
7. Check HTML template errors
8. Check property names and wire response
9. Check permissions and field-level security
10. Check cache issue
Example:
[Link]('Record Id:', [Link]);
[Link]('Data:', [Link](data));
[Link]('Error:', [Link](error));

18. How do you debug Apex call from LWC?


Answer:
I debug both client side and server side.
In LWC:
handleClick() {
getAccounts()
.then(result => {
[Link]('Accounts:', [Link](result));
})
.catch(error => {
[Link]('Error:', [Link](error));
});
}

In Apex:
@AuraEnabled(cacheable=true)
public static List<Account> getAccounts() {
[Link]('Inside getAccounts method');

return [
SELECT Id, Name
FROM Account
LIMIT 10
];
}

If there is an error, I check browser console, network tab, and debug logs.

19. What is the difference between [Link] and [Link]?


Answer:

[Link] [Link]
[Link] [Link]
Used in JavaScript/LWC Used in Apex
Output appears in browser console Output appears in Salesforce debug logs
Client-side debugging Server-side debugging

Example:
[Link]('LWC value:', [Link]);

[Link]('Apex value: ' + [Link]);

20. How do you debug @wire in LWC?


Answer:
I check both data and error.
@wire(getAccounts)
wiredAccounts({ data, error }) {
if(data) {
[Link]('Data:', [Link](data));
[Link] = data;
} else if(error) {
[Link]('Error:', [Link](error));
}
}

Common issues:
1. Apex method not marked @AuraEnabled(cacheable=true)
2. Wrong import
3. Parameter mismatch
4. Apex exception
5. FLS or sharing issue
6. Cache issue

21. How do you debug imperative Apex call in LWC?


Answer:
Imperative calls use promise syntax.
import getAccounts from '@salesforce/apex/[Link]';

getAccounts()
.then(result => {
[Link]('Result:', [Link](result));
})
.catch(error => {
[Link]('Error:', [Link](error));
});

If result is not coming, I check:


1. Browser console
2. Network tab
3. Apex debug log
4. Method name and import path
5. @AuraEnabled
6. User permissions

22. How do you debug API callout issues?


Answer:
For callout issues, I check:
1. Remote Site Setting or Named Credential
2. Endpoint URL
3. HTTP method
4. Request body
5. Headers
6. Authentication token
7. Status code
8. Response body
9. Timeout
10. Debug logs with Callout level enabled
Example:
HttpRequest req = new HttpRequest();
[Link]('callout:My_Named_Credential/api/users');
[Link]('GET');

Http http = new Http();


HttpResponse res = [Link](req);

[Link]('Status Code: ' + [Link]());


[Link]('Response Body: ' + [Link]());

23. How do you debug “Callout from triggers are currently not supported”?
Answer:
Salesforce does not allow direct HTTP callouts from triggers.
Wrong:
trigger AccountTrigger on Account (after insert) {
// Direct callout here is not allowed
}

Correct approach: use asynchronous Apex like @future(callout=true) or Queueable


Apex.
public class AccountCalloutService {
@future(callout=true)
public static void sendAccountData(Set<Id> accountIds) {
// Callout logic here
}
}

From trigger:
[Link](accountIds);

24. How do you debug async Apex?


Answer:
For async Apex like Future, Queueable, Batch, and Scheduled Apex, I check:
1. Setup -> Apex Jobs
2. Debug logs for Automated Process user or running user
3. Async job status
4. Exception stack trace
5. Number of batches processed
6. Failed jobs
7. Flex Queue
For Queueable:
[Link](new MyQueueableClass());

Then check Apex Jobs.

25. How do you debug Batch Apex?


Answer:
I check:
1. Start method query
2. Batch size
3. Execute method logs
4. Finish method
5. Apex Jobs
6. Failed record details
7. Governor limits inside each batch
Example:
[Link](new MyBatchClass(), 100);

If it fails, I check the error in Apex Jobs and then enable logs for the running user.

26. How do you debug permission-related issues?


Answer:
I check:
1. Profile permissions
2. Permission sets
3. Object permissions
4. Field-level security
5. Record-level access
6. Sharing rules
7. Role hierarchy
8. Manual sharing
9. Restriction rules
10. Login as user and reproduce issue
Common error:
INSUFFICIENT_ACCESS_OR_READONLY
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

In Apex, I also check whether the class is running with sharing, without sharing, or
inherited sharing.

27. What is the difference between with sharing and without sharing?
Answer:
with sharing respects record-level sharing rules.
public with sharing class AccountService {
}

without sharing ignores record-level sharing rules.


public without sharing class AccountService {
}

But both do not automatically enforce object-level and field-level security. For that, we
should use security checks like WITH SECURITY_ENFORCED or
[Link]().
28. How do you debug SOQL query issues?
Answer:
I check:
1. Object API name
2. Field API names
3. Relationship names
4. Filter condition
5. User permissions
6. Record visibility
7. Query limits
8. Null values
9. Date filters
10. Record type filters
Example issue:
List<Contact> contacts = [
SELECT Id, [Link]
FROM Contact
WHERE AccountId != null
];

For child relationship queries, relationship name should be correct:


List<Account> accounts = [
SELECT Id, Name,
(SELECT Id, LastName FROM Contacts)
FROM Account
];

29. How do you debug CPU timeout issue?


Answer:
CPU timeout happens when transaction takes too much processing time.
I check:
1. Nested loops
2. SOQL/DML inside loops
3. Recursive automation
4. Heavy Flows
5. Process Builder
6. Complex validation rules
7. Too much data processing
8. Inefficient map/list usage
Solution:
1. Bulkify code
2. Use maps instead of nested loops
3. Move heavy logic to async Apex
4. Reduce unnecessary automation
5. Optimize SOQL filters
6. Avoid repeated calculations

30. How do you debug mixed DML error?


Answer:
Mixed DML happens when we perform DML on setup and non-setup objects in the same
transaction.
Setup object examples:
User
PermissionSetAssignment
Group
QueueSObject
UserRole

Non-setup object examples:


Account
Contact
Opportunity
Case

Example error:
MIXED_DML_OPERATION

Solution: move one operation to async Apex.


@future
public static void assignPermissionSet(Id userId) {
// PermissionSetAssignment DML here
}

31. How do you debug validation rule errors?


Answer:
I check the error message and then go to:
Object Manager -> Object -> Validation Rules
Then I check:
1. Rule condition
2. Fields used in formula
3. Whether the value meets the condition
4. User/profile exceptions
5. Custom permission bypass logic
Example validation rule:
AND(
ISPICKVAL(Status__c, 'Closed'),
ISBLANK(Resolution__c)
)

If record status is Closed and Resolution is blank, the validation rule will fire.

32. How do you debug “CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY”?


Answer:
This is a generic error which means some automation failed.
It can come from:
1. Apex trigger
2. Flow
3. Process Builder
4. Workflow
5. Managed package automation
To debug it, I check the full error message and debug log. Usually, the actual root cause is
written after this error.
Example:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: AccountTrigger: execution of
AfterUpdate caused by: [Link]

Here actual error is NullPointerException inside AccountTrigger.

33. How do you debug record locking error?


Answer:
Record locking error usually appears as:
UNABLE_TO_LOCK_ROW

It happens when two transactions try to update the same record at the same time.
I debug by checking:
1. Parent-child record updates
2. Roll-up summary fields
3. Batch jobs
4. Parallel data loads
5. Trigger updates on parent records
6. Sharing recalculation
Solutions:
1. Use smaller batch size
2. Avoid parallel updates on same parent
3. Use serial mode in Data Loader
4. Optimize trigger logic
5. Retry failed records

34. How do you debug sharing/access issue in Apex?


Answer:
I check:
1. Class sharing keyword
2. User profile
3. Permission sets
4. OWD settings
5. Sharing rules
6. Role hierarchy
7. Manual shares
8. Restriction rules
9. Object and field permissions
Example:
public with sharing class CaseController {
@AuraEnabled
public static List<Case> getCases() {
return [SELECT Id, Subject FROM Case];
}
}

If user cannot see some cases, it may be because with sharing is respecting record access.

35. How do you debug production issue without changing code?


Answer:
I can debug production issues using:
1. Debug logs
2. Trace flags
3. Login as user
4. Setup Audit Trail
5. Field History Tracking
6. Flow error emails
7. Apex Jobs
8. Exception emails
9. Event Monitoring
10. Reproduce issue in sandbox
I avoid adding too many [Link]() statements directly in production unless
absolutely required.

36. How do you debug an issue where record is not getting created?
Answer:
I check:
1. Required fields
2. Validation rules
3. Duplicate rules
4. Trigger errors
5. Flow errors
6. Permission issues
7. Record type access
8. Page layout required fields
9. Lookup field access
10. Debug logs
If it is created from Apex, I use try-catch or [Link](records, false) to capture
record-level errors.

37. How do you debug an issue where field value is getting overwritten?
Answer:
I check Salesforce order of execution.
Possible reasons:
1. Before-save flow
2. Before trigger
3. Validation rule
4. After trigger
5. Assignment rule
6. Workflow field update
7. Process Builder
8. After-save flow
9. Roll-up summary
10. Managed package logic
I enable debug logs and search for the field API name to see where it is being updated.

38. How do you debug email not being sent from Salesforce?
Answer:
I check:
1. Email Deliverability setting
2. Organization-wide email address
3. Email template
4. Recipient email field
5. User email permissions
6. Apex email limits
7. Email logs
8. Spam/junk folder
9. Workflow/Flow email alert criteria
In Apex:
[Link] mail = new [Link]();
[Link](new String[] {'test@[Link]'});
[Link]('Test Email');
[Link]('This is a test email');

[Link](new [Link][] { mail });

39. How do you debug integration failure?


Answer:
I check:
1. Endpoint URL
2. Named Credential
3. Authentication
4. Request method
5. Headers
6. Payload/body
7. Response status code
8. Response body
9. Timeout
10. Remote system logs
11. Salesforce debug logs
Example:
[Link]('Request Body: ' + requestBody);
[Link]('Status Code: ' + [Link]());
[Link]('Response: ' + [Link]());

40. What would you do if user says “I am getting an error but I don’t know
why”?
Answer:
I would follow a structured approach:
1. Ask for exact error message.
2. Ask which user is facing the issue.
3. Ask steps to reproduce.
4. Enable debug log for that user.
5. Reproduce the issue.
6. Analyze debug log.
7. Identify whether issue is from Apex, Flow, validation rule, permission, or
integration.
8. Fix in sandbox.
9. Test with positive and negative scenarios.
10. Deploy using proper change set or deployment tool.

Scenario-Based Debugging Questions


Scenario 1: User is unable to save Opportunity. What will you check?
Answer:
I will check:
1. Error message
2. Validation rules
3. Required fields
4. Record type access
5. Stage-related required fields
6. Flow or trigger errors
7. Duplicate rules
8. Debug logs
9. User permissions
10. Related lookup record access

Scenario 2: LWC button click is not working. How will you debug?
Answer:
I will check:
1. Whether onclick is correctly written in HTML
2. Whether JS method name is correct
3. Browser console errors
4. Whether button is disabled
5. Whether Apex call is failing
6. Network tab
7. JavaScript import issues
8. Component visibility
9. User permissions
Example:
<lightning-button
label="Save"
onclick={handleSave}>
</lightning-button>

handleSave() {
[Link]('Save button clicked');
}

Scenario 3: Apex class works for one record but fails for bulk upload. Why?
Answer:
This usually happens because code is not bulkified.
Possible problems:
1. SOQL inside loop
2. DML inside loop
3. Too many queries
4. Too many DML statements
5. CPU timeout
6. Heap size issue
Solution is to use collections like List, Set, and Map.
Scenario 4: Record-triggered Flow is not firing. What will you check?
Answer:
I will check:
1. Flow is active or not
2. Correct object selected
3. Entry conditions
4. Created/updated condition
5. Before-save or after-save flow
6. User permission
7. Record values
8. Whether another automation changed the value
9. Debug the flow with sample record
10. Debug log

Scenario 5: Apex test class is failing. How will you debug?


Answer:
I will check:
1. Error message
2. Test data setup
3. Required fields
4. Validation rules
5. Record type
6. User permissions using [Link]
7. SeeAllData usage
8. Assertions
9. Trigger side effects
10. Debug logs from test execution
Example:
@isTest
private class AccountTest {
@isTest
static void testAccountInsert() {
Account acc = new Account(Name = 'Test Account');
insert acc;

[Link](null, [Link]);
}
}
Scenario 6: API callout is failing with 401 Unauthorized. What will you check?
Answer:
I will check:
1. Authentication token
2. Named Credential
3. Connected App
4. Client ID and secret
5. OAuth scope
6. Token expiry
7. Authorization header
8. Remote system permissions
401 usually means authentication failed.

Scenario 7: API callout is failing with 500 error. What will you check?
Answer:
500 error means server-side error from external system.
I will check:
1. Request body
2. Required fields in payload
3. Endpoint
4. External system logs
5. Response body
6. Whether same request works in Postman
7. Payload format JSON/XML
8. Headers like Content-Type

Scenario 8: User can see button, but another user cannot. How will you debug?
Answer:
I will check:
1. Profile
2. Permission set
3. Lightning page visibility filter
4. Dynamic actions
5. Object permissions
6. Record type
7. App assignment
8. Custom permission
9. Component visibility rule
10. User license

Scenario 9: A field is visible to admin but not visible to user. What will you
check?
Answer:
I will check:
1. Field-level security
2. Page layout
3. Lightning record page
4. Dynamic forms
5. Permission sets
6. Record type-specific page layout
7. Profile permissions

Scenario 10: A scheduled job is not running. What will you check?
Answer:
I will check:
1. Scheduled Jobs in Setup
2. Apex Jobs
3. Cron expression
4. Running user status
5. Class access
6. Apex exception
7. Deployment changes
8. User permissions
9. Whether job was aborted

Strong Interview Answer Format


Use this format when answering debugging questions:
“First, I reproduce the issue. Then I enable debug logs for the affected user. I check
the exact error, stack trace, SOQL/DML statements, automation execution, and
permissions. Based on the root cause, I fix it in sandbox, test different scenarios, and
then deploy.”
Example answer:
“If a record is not saving, I first check the exact error message. Then I enable debug
logs for that user and reproduce the issue. In the log, I check whether the error is
coming from validation rule, trigger, flow, duplicate rule, or permission issue. Once I
identify the root cause, I fix it in sandbox and test with multiple users and record
types.”

You might also like