Tag: salesforce
-
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…
-
How to Pass a Variable from One Apex Class to Another?
Question I have an Apex class (MyCTIExtensions) that retrieves a phone number and stores it in a static variable (phoneNumber). When certain conditions are met (cases.size() > 1), the class calls a Visualforce page. The Visualforce page’s controller (FlowRedirectController) is supposed to retrieve this phoneNumber and use it to construct a URL for a Flow.…
-
How Can I Delete Triggers and Classes from Production?
Question I was told that classes and triggers cannot be deleted directly in Production. Instead, they must be deleted in a Sandbox and then deployed as deletions. However, after deleting a class in Sandbox, it does not appear as a deployable change—red or otherwise. Do deleted triggers/classes show up somewhere else for deployment? Does this…
-
How is Aggregate Code Coverage Calculated in Salesforce?
Question How does Salesforce calculate aggregate code coverage when multiple Apex classes are involved? Is it based on the average coverage per class or the ratio of covered lines to total testable lines? Answer Salesforce determines aggregate code coverage using the ratio of all covered lines to the total testable lines in the org, not…
-
How to Retrieve Tabs, Apps, and Apex Classes in Salesforce?
Question I am using sf project retrieve to pull metadata from my Salesforce Dev Hub into my local project. My package.xml retrieves Apex triggers but does not fetch custom applications (Lightning apps), custom tabs, Apex classes, or custom fields. How can I modify package.xml to retrieve them? Answer In Salesforce, retrieving metadata using sf project…