Category: Salesforce

  • How to Retrieve Named Principal Values in Apex?

    How to Retrieve Named Principal Values in Apex?

    Question I have a scenario where I need to generate an additional token before making a callout. This token requires API_KEY and API_SECRET, which I have stored in Named Principals. The usual approach, as mentioned in Salesforce documentation and forums, is to use the following formula: However, this does not work because the formula is…

  • How to Check Record Type in a Loop?

    How to Check Record Type in a Loop?

    Question However, I can’t access the record type ID of LinkedEntityId directly in the loop. I tried: But I get the error:“Method does not exist or incorrect signature: void getRecordTypeId() from the type Id.” How can I correctly retrieve and compare the record type ID in this scenario? Answer Since the system does not allow…

  • How to Perform HTTP Callout from Apex Trigger?

    How to Perform HTTP Callout from Apex Trigger?

    Question I have a trigger on a custom object that invokes an Apex class to make an HTTP GET request to an external web service. However, I encounter the following error: “Callout from triggers are currently not supported.” I understand that I can use an @future method to perform an asynchronous callout, but @future methods…

  • Why Is My SF Project Deployment Not Updating?

    Why Is My SF Project Deployment Not Updating?

    Question For the past two weeks, I’ve been encountering an issue with deploying code to my Production Org using the sf project deploy start command in VS Code. While the command runs successfully in the terminal without any errors and the deployment appears in the org’s Deployment Status as successful, the code doesn’t seem to…

  • How to Query Polymorphic Fields in SOQL?

    How to Query Polymorphic Fields in SOQL?

    Question: When working with polymorphic fields like Owner or What in Salesforce, which can reference multiple object types, how can I construct a SOQL query that avoids errors when querying fields that may not exist on all possible related objects? For example, if I query the Owner field and include fields specific to User or…

  • What Should Be Global in a Packaged @InvocableMethod?

    What Should Be Global in a Packaged @InvocableMethod?

    Question I’m developing an @InvocableMethod action in Apex that will be included in a managed package. The Salesforce documentation appears inconsistent regarding what elements need to be marked global. From my testing, I have observed that the top-level class must be global. The @InvocableMethod itself seems to work when left public. Inner classes used for…

  • How to Send Case Survey to SuppliedEmail on Case Closure?

    How to Send Case Survey to SuppliedEmail on Case Closure?

    Question I have created a survey to collect customer feedback, and I would like to send it to the email address in the “SuppliedEmail” field on the Case. I have explored using Case Auto-Response Rules and the Support Settings – Customer Feedback Survey, but I was unable to find a way to send the survey…

  • Can Named Credential merge fields be used in URLs?

    Can Named Credential merge fields be used in URLs?

    Question You might want to pass dynamic values such as authentication details into the URL for an external service using Named Credentials. However, the issue arises because merge fields like {!$Credential.Password} or {!$Credential.UserName} do not get decoded until the request is actually sent, making it difficult to directly pass these as URL parameters. You’ve tried…

  • How to Get Dependent Picklist Options in Apex?

    Question How to Retrieve Dependent Picklist Values in Apex? I am working with a pair of dependent picklists and need to determine the valid options in the dependent field for each value in the controlling field using Apex. Here’s an example setup: I’ve attempted to use getPicklistValues(), but it doesn’t provide dependency information. Ideally, I’m…

  • How to Notify When Attachment Added to Custom Object?

    How to Notify When Attachment Added to Custom Object?

    Question You want to send an email notification whenever an attachment is uploaded to a custom object in Salesforce. Attachments in Salesforce are now represented as ContentDocument records, and their relationship to other records is managed through ContentDocumentLink objects. The challenge lies in correctly identifying when an attachment is associated with your custom object because…

Open Chat
1
Dear Sir/Madam
How can I help you?