Uncommitted Work Pending in Test with System.runAs?
Question: I am writing a test class where I need to run the test as two different users, because the approveForm method contains a validation that prevents the creator of the form from approving it. In my test for approval, I am consistently running into the “Uncommitted work pending” issue,…
Sending Form-Data in Apex Callout to Auth0?
Question: I need to send a multipart/form-data request from Salesforce Apex to Auth0’s /api/v2/jobs/users-imports endpoint. I have limited experience working with form-data requests. I structured the request body as follows: My Apex code: However, I keep getting this error response: What is wrong with my request, and how can I…
How to Block Recursion in a Generic Trigger Handler?
Question When implementing a generic trigger handler that processes all TriggerOperation types and supports arbitrary SObjectType, recursion can become a major issue. Recursion occurs when a trigger causes an update that invokes the same trigger again, leading to infinite loops or redundant processing. Consider the following example trigger: With the…
Combobox Performance Issue in LWC?
Question: I am facing a performance issue with a combobox in LWC. I found similar questions suggesting that using the spread operator on the data should work, but it still takes a lot of time to load. However, when I pass the data as a JSON string and parse it,…
Contact Mass Update – Apex CPU Time Limit Exceeded?
Question I am trying to perform a mass update on Contact records using Execute Anonymous, but I keep getting the following error: System.LimitException: Apex CPU Time Limit Exceeded Here is the code I am using: What is causing this error, and how can I optimize my approach to avoid hitting…
Updating PermissionSetTabSetting Without Metadata API?
Question: I need to update the visibility settings for tabs within a Permission Set in Apex. I successfully retrieved PermissionSetTabSetting records but encountered an issue when trying to upsert changes in a loop. Here’s my approach: However, I keep getting this error:System.DmlException: Upsert failed. First exception on row X; first…
Why Should Unit Tests Avoid Data Silos?
Question: Why is it important to create our own data when writing unit tests? Many developers advise against using seeAllData=true, but the reasoning is often not fully explained. How do data silos impact test consistency, reliability, and troubleshooting across different environments? Answer: The key reason for avoiding data silos in…
APEX Test Class Failures in Production?
Question: I’m trying to deploy an additional field into an existing Aura component bundle in my production org to improve the user interface. However, I keep encountering APEX test failures on the following test classes: CalculateexchangerateTest and UpdatePBTest. I am not proficient in APEX and did not build these test…
Testing Apex That Relies on Field History Tracking?
Question I have Apex code that queries the history records of a custom object using field history tracking. This works fine in a real environment, but when I run my unit tests, no history records are created, causing my tests to fail. How can I test code that depends on…
Bounced Emails and Email Confirmation in Salesforce?
Question In Salesforce, when an email bounces, the system marks it with a bounce warning and provides details near the email address. In Lightning Experience, this information appears as an alert near the email field. However, in Salesforce Classic, an additional “Confirm Email Address” link is available. Does the “Confirm…

