Mixed DML Operation Error in Salesforce?
Question: I am encountering a MIXED_DML_OPERATION error when trying to perform DML operations on setup objects (e.g., Custom Settings) and non-setup objects (e.g., Lead) in the same transaction. Here’s a snippet of my test class: When running this code, I receive the following error: How can I resolve this issue…
How to resolve Record is read-only error in trigger?
Question: I am writing a trigger to populate the competitors’ names into a custom field on Opportunity. However, while testing, I am getting the following error message: System.FinalException: Record is read-only: Trigger.updateCompetitors: line 24 Here’s the trigger code I’ve written: I am encountering the error on line 24, which is…
Ghost Schedulable Jobs Blocking Deployment?
Question: Why does Salesforce block deployments due to schedulable jobs when there are no visible pending or in-progress jobs for the associated class? I’ve cleared all schedulable jobs from the class, but the issue persists. Are there ways to handle or resolve this problem? I’ve tried querying all CronTrigger objects…
Apex Callout Fails Due to SunCertPathBuilderException?
Question I am trying to make an Apex callout from Salesforce to an external system hosted inside a corporate firewall. The firewall forwards the request to a load balancer, which then routes it to the appropriate web server. While the callout works correctly when tested from SOAP UI, it fails…
How to Customize Fields in Add Products Button?
Question: When I click the standard Add Products button in Salesforce (e.g., on an Opportunity), the resulting screen displays certain fields as columns, which seem to come from the Product search layout. However, after selecting products, I am taken to another screen where I want to display additional custom fields…
How to Filter Opportunity Owner ID in a Report?
Question: When building a report programmatically using Apex, how can we set up a filter for “Owner ID equals” using a ReportFilter from the Reports namespace? Specifically, what is the correct column name for the Owner ID field on the standard Opportunity object? I tried the following code, but it…
What Are the Available Static Code Analysis Tools for Apex?
Question What Are the Best Static Code Analysis Tools for Apex? I’m looking for static code analysis tools specifically designed for Apex development. While the Force.com Security Source Code Scanner is a well-known option, it has the limitation of operating through a queue system, which can delay the analysis. I’m…
Can the Metadata API Be Invoked from Apex?
Question: Is it possible to use the Salesforce Metadata API from within Apex? Can the Metadata API be invoked from Apex? Many sources state that Salesforce doesn’t allow callouts to its own web services from within Salesforce. However, other posts and resources suggest it might be achievable, especially for specific…
How to generate a GUID/UUID in Apex?
Question: What is the best way to generate a GUID/UUID in Apex, particularly in the format nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn? For example, a valid UUID might look like 13219ec0-3a81-44c5-a300-de14b7d0235f. This functionality would be useful in scenarios like assigning unique identifiers to records in triggers. Answer: Below is a reusable class in Apex for…
Dynamic Scale for Currency Field in Salesforce?
Question How to Correctly Create a Transaction Security Policy via the Tooling API? I am attempting to create a Transaction Security Policy using the Tooling API, but I’m facing challenges with the JSON structure. I’ve tried several variations, but none seem to work. Below are my attempts and the errors…

