Category: Salesforce
-
Fixing ‘set on proxy’ Error in LWC
When working with Lightning Web Components (LWC), you may run into the following error while trying to update a field on a Contact record fetched via an Apex method This typically occurs when you fetch data using a @wire service with an Apex method marked as cacheable=true. In such cases, Salesforce provides the data as…
-
Can Salesforce Report Data Be Accessed Programmatically?
Question It is common for developers to wonder if existing Salesforce reports and their data can be accessed directly in Apex, instead of replicating the report logic with SOQL queries. Manually writing SOQL queries would require code changes every time the report is updated, which is not efficient. So the question is: is there a…
-
How can I get a valid Session ID in Lightning?
Question When working with the Apex Wrapper Salesforce Metadata API, developers often need a valid API-capable session ID to perform operations such as updating picklist values dynamically. In Salesforce Classic, it is possible to retrieve a valid session ID using UserInfo.getSessionId() and pass it into an asynchronous method for Metadata API callouts. However, in Salesforce…
-
Lightning Message Channels in Background Utility Items?
Question I am trying to get a Background Utility Item (using Aura) to listen for and propagate some events from the Workspace API. After setting up my Lightning Message Channel and writing both a publisher and subscriber, I noticed that the subscriber is not receiving any events. When I checked the browser console, I saw…
-
Why Does My Apex Callout Fail with SunCertPathBuilderException?
Question I am trying to make an Apex callout from Salesforce to an external system that is hosted inside a corporate firewall. The firewall forwards the request to a load balancer, which then routes it to the appropriate web server. However, when I attempt the callout from Salesforce, I encounter the following error: The same…
-
Mass Updating Contacts Causes “Apex CPU Time Limit Exceeded”?
Question I’m attempting to perform a mass update on Contacts using Execute Anonymous, but I keep encountering the following error: System.LimitException: Apex CPU Time Limit Exceeded Here’s the code I’m using: Why is this happening, and how can I optimize my approach to avoid hitting the CPU time limit? Answer The Apex CPU time limit…
-
How to Pass Parameters to a Lightning Component Quick Action?
Question I have a Lightning Component that is used as a Lightning Component Quick Action. This component needs to be added to different objects, such as Account and Contact, as a quick action. The challenge I am facing is determining which object the component was invoked from. While I can retrieve the record Id using:…
-
How Can I Call the Salesforce API from a Lightning Component?
Question I need to call the Apex Wrapper Metadata API from a Lightning component, but I am facing an issue where there is no native support for acquiring a valid API session ID from an @AuraEnabled method in an Apex controller. Salesforce documentation suggests using a Named Credential to bypass this security restriction. However, when…
-
How Can I Create a Chatter File Using Apex?
Question In the Chatter tab, I can navigate to “Files” and upload a file without attaching it to any specific record. I want to achieve the same functionality purely through Apex. How can this be done? Answer Yes, you can create a Chatter File (Salesforce File) using Apex by working with the ContentVersion object. Salesforce…
-
Does Salesforce Named Credentials Support OAuth2 Client Credentials Grant?
Question I need to authenticate an external API using OAuth2 Client Credentials Grant and prefer using Salesforce Named Credentials to handle authentication, token storage, and refresh automatically. However, I haven’t found clear documentation confirming its support for this grant type. From my research, Named Credentials primarily support OAuth flows like Authorization Code Grant and OpenID…