Why Does Salesforce CLI Authentication Fail in VS Code?
Question When trying to authenticate a Salesforce org in VS Code, the process successfully redirects to the browser for login, and after entering credentials, the browser confirms “Authentication successfully.” However, in VS Code, the status remains stuck at “in progress,” and if canceled, the following error message appears: Answer This…
How to filter Opportunity Owner ID in a report using Apex?
Question: When building a report programmatically using Apex, how can you set up a filter for the “Owner ID” field on the Opportunity object? Specifically, I tried to use the ReportFilter from the Reports namespace to set the filter for the Owner ID but encountered errors. Here’s the code I…
How Does Test Coverage Work for Enums and Properties in Apex?
Question: I recently noticed some unusual behavior in Apex test coverage and wanted to confirm whether this has always been the case or if something has changed over time. Specifically, I observed that: Consider the following class containing only an enum: Even when this enum is used in test cases,…
Loop with SOQL or List, Which is Better?
Question: When working with Salesforce Apex, is it better to use a SOQL query directly within a for loop, or to query the records into a list first and then iterate through that list? Considerations include performance, memory usage, and specific use cases. Here are two examples of the approaches…
Managing Batch Execution Without DML Limits in Salesforce
Question How to Create Accounts with Multiple Contacts in Salesforce Without Exceeding DML Limits? I am trying to create accounts and associate 1,000 contacts with each account in Salesforce using a batch class. When managing batch execution without DML limits in Salesforce, I can successfully handle the required number of…
Can You Set Lookup Fields with __r and External IDs?
Question Is it possible to set a lookup field in Apex by using the relationship field (__r) and an external ID? For example, can we relate a child record to its parent by specifying the parent object with just an external ID value? If yes, how does it work, and…
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…

