Batch Apex runs in multiple transactions, and failures often depend on data distribution rather than logic. A specific batch chunk may hit governor limits, record locks, or validation errors that don’t exist in other chunks. Because batches process subsets of data, the same code path might encounterRead more
Batch Apex runs in multiple transactions, and failures often depend on data distribution rather than logic. A specific batch chunk may hit governor limits, record locks, or validation errors that don’t exist in other chunks.
Because batches process subsets of data, the same code path might encounter edge cases only under certain data conditions. This makes failures appear random even though they’re data-driven.
Improving batch reliability usually involves adding defensive checks, better exception handling, and logging failed record IDs for analysis.
Takeaway: Batch failures are usually caused by edge-case data, not random system behavior.
Why does my Salesforce Flow create duplicate records even with entry conditions?
The Flow is triggered multiple times due to record updates or automation recursion. Problem Explanation Record-triggered Flows can re-run when the same record is updated by another Flow, Process Builder, or Apex, causing duplicate record creation. Root Cause(s) 1. Flow runs on create and update 2. NRead more
The Flow is triggered multiple times due to record updates or automation recursion.
Problem Explanation
Record-triggered Flows can re-run when the same record is updated by another Flow, Process Builder, or Apex, causing duplicate record creation.
Root Cause(s)
1. Flow runs on create and update
2. No duplicate-check logic
3. Another automation updates the same record
4. Before-save and after-save Flows both active
Step-by-Step Solution
1. Change trigger to Only when record is created
2. Add a Decision element to check for existing records
3. Use a unique field (Email, External ID)
4. Disable redundant automation
Edge Cases & Variations
1. Integration updates can retrigger Flows
2. Bulk updates amplify duplicates
Common Mistakes to Avoid
1. Relying only on entry criteria
2. Ignoring update-triggered executions
See lessWhy does my Apex future method not execute?
The method violates async execution rules. Problem Explanation Future methods require strict signatures and cannot be chained improperly. Root Cause(s) 1. Non-static method 2. Unsupported parameter types 3. Called from another async context Step-by-Step Solution 1. Mark method @future and static 2.Read more
The method violates async execution rules.
Problem Explanation
Future methods require strict signatures and cannot be chained improperly.
Root Cause(s)
1. Non-static method
2. Unsupported parameter types
3. Called from another async context
Step-by-Step Solution
1. Mark method
@futureandstatic2. Use primitive parameters only
3. Avoid calling from batch or future
Edge Cases & Variations
1. Apex is more flexible
2. Limits differ between async types
Common Mistakes to Avoid
1. Passing sObjects
2. Expecting immediate execution
See lessWhy does my SOQL query fail with “MALFORMED_QUERY: unexpected token”?
There is a syntax error in your SOQL statement. Problem Explanation SOQL is strict about keywords, spacing, and field names. Root Cause(s) 1. Missing commas 2. Reserved keywords as field names 3. Incorrect relationship syntax Step-by-Step Solution 1. Validate query in Developer Console 2. Check relaRead more
There is a syntax error in your SOQL statement.
Problem Explanation
SOQL is strict about keywords, spacing, and field names.
Root Cause(s)
1. Missing commas
2. Reserved keywords as field names
3. Incorrect relationship syntax
Step-by-Step Solution
1. Validate query in Developer Console
2. Check relationship names via Schema Builder
3. Avoid dynamic string concatenation errors
Edge Cases & Variations
1. API version differences affect functions
2. Aggregate queries require GROUP BY
Common Mistakes to Avoid
1. Assuming SQL == SOQL
2. Using wrong child relationship names
See lessHow do I prevent recursive trigger execution in Salesforce?
Use a static Boolean flag or a trigger handler pattern. Problem Explanation Triggers can fire repeatedly due to record updates caused by automation or Apex logic. Root Cause(s) 1. Update DML inside triggers 2. Workflow, Flow, or Process Builder updates 3. Missing recursion control Step-by-Step SolutRead more
Use a static Boolean flag or a trigger handler pattern.
Problem Explanation
Triggers can fire repeatedly due to record updates caused by automation or Apex logic.
Root Cause(s)
1. Update DML inside triggers
2. Workflow, Flow, or Process Builder updates
3. Missing recursion control
Step-by-Step Solution
1. Create a static variable in a helper class
2. Exit trigger logic if flag is already set
public class TriggerControl {
public static Boolean isRunning = false;
}
Edge Cases & Variations
1. Multiple triggers require a shared handler
2. Flows can still cause recursion indirectly
Common Mistakes to Avoid
1. Using non-static variables
2. Relying only on trigger context
See lessWhy does my Apex test class fail with “Mixed DML Operation” error?
You’re modifying setup and non-setup objects in the same transaction. Problem Explanation Salesforce separates setup objects (User, Profile) from standard objects to maintain system integrity. Root Cause(s) 1. Creating Users and Accounts together 2. Updating Permission Sets alongside data records 3.Read more
You’re modifying setup and non-setup objects in the same transaction.
Problem Explanation
Salesforce separates setup objects (User, Profile) from standard objects to maintain system integrity.
Root Cause(s)
1. Creating Users and Accounts together
2. Updating Permission Sets alongside data records
3. Test setup not isolated
Step-by-Step Solution
1. Move setup object DML to
System.runAs()2. Separate transactions using
@testSetup3. Use async Apex for one side if required
Edge Cases & Variations
1. Permission Set Assignments count as setup DML
2. Community Users increase complexity
Common Mistakes to Avoid
1. Creating users inside main test method
2. Ignoring setup vs non-setup distinction
See lessWhy does my validation rule fail during data migration?
Validation rules apply during imports unless bypassed. Problem Explanation Data Loader, APIs, and integrations enforce validation rules just like UI operations. Root Cause(s) 1. No bypass condition 2. Required fields missing in import 3. Incorrect formula logic Step-by-Step Solution 1. Add custom peRead more
Validation rules apply during imports unless bypassed.
Problem Explanation
Data Loader, APIs, and integrations enforce validation rules just like UI operations.
Root Cause(s)
1. No bypass condition
2. Required fields missing in import
3. Incorrect formula logic
Step-by-Step Solution
1. Add custom permission bypass
2. Assign permission to integration user
3. Update validation rule condition
Edge Cases & Variations
1. Bulk API behaves same as UI
2. Managed rules cannot be bypassed
Common Mistakes to Avoid
1. Disabling rules permanently
2. Using profile-based checks
See lessWhy does my Salesforce test class pass locally but fail in CI deployment?
The target org has different data, settings, or automation. Problem Explanation CI environments expose hidden dependencies and stricter validations. Root Cause(s) 1. Hardcoded IDs 2. Missing test data 3. Environment-specific automation Step-by-Step Solution 1. Remove hardcoded references 2. Create cRead more
The target org has different data, settings, or automation.
Problem Explanation
CI environments expose hidden dependencies and stricter validations.
Root Cause(s)
1. Hardcoded IDs
2. Missing test data
3. Environment-specific automation
Step-by-Step Solution
1. Remove hardcoded references
2. Create complete test data
3. Disable conflicting automation if needed
Edge Cases & Variations
1. Sandboxes differ from production
2. Feature flags affect behavior
Common Mistakes to Avoid
1. Relying on org configuration
2. Ignoring CI logs
See less