Category: Salesforce

  • 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.…

  • Why is sfdx update not working on my laptop?

    Question I’m trying to update the Salesforce CLI using sfdx update, but it keeps failing with the following error: I have tried running the update in a Command Prompt with Administrator privileges. I also uninstalled the CLI and reinstalled it using sf-x64.exe. I can install the CLI from scratch without any issues, but updating it…

  • Why Are Refresh Tokens Expiring? – Salesforce Connected App

    Question We have configured our web application to authenticate with Salesforce using OAuth2 via a Connected App. The Connected App is set up to ensure that refresh tokens never expire unless manually revoked. When an admin connects the Connected App to our web application, we securely store the received refresh token so that we can…

  • 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…

  • How Do I Write an Apex Unit Test?

    Question Writing unit tests in Apex is an essential practice for ensuring code quality, maintaining stability, and meeting Salesforce’s deployment requirements. A well-written unit test follows structured principles to verify that your code behaves as expected. Answer Understanding Apex Unit Tests Apex unit tests follow three essential steps: Create test data: Before executing your code,…

  • Why Does EncryptSymmetric() in AMPScript Produce Different AES Results?

    Question We are trying to encrypt and encode URL parameters in Salesforce Marketing Cloud using the EncryptSymmetric() function with the AES algorithm. Following the documentation, we used the following AMPScript: The function returned: However, decrypting this value using an online AES tool resulted in an error. Encrypting the same string with an online AES-128 tool…

  • How Can I Integrate Salesforce with JIRA?

    Question I have been looking for an easy way to integrate Salesforce with JIRA and have gone through JIRA’s documentation. I also tried a few AppExchange packages, but they only support standard objects. However, my use case requires integrating a custom object in Salesforce with JIRA issues. What are some easy ways to achieve this…