Skip to main content

#Sales Cloud148 discussing

1 answer
  1. Sep 21, 8:47 PM

    Hi Suraj,

    To write a unit test for a @future (callout=true) method, you need to mock the HTTP callout (using HttpCalloutMock) and enclose the execution between Test.startTest() and Test.stopTest(). Salesforce runs all asynchronous methods (like future methods) called within startTest() and stopTest() synchronously right when Test.stopTest() executes. 

     

    Here is an example test class structure to cover your method:

    1.Create a Mock Callout Class:

    Mock Implementation. 

    Create a mock class that implements HttpCalloutMock to return a fake JSON response simulating your patchCall output (ensuring it contains 'state' => 'Success' and a valid JSON structure with an id field).

    2.Prepare Test Data and Context:

    Test Setup. 

    In your test method, insert a test Bid_Review_Request__c record so that the update brUpdate; statement can successfully find and update a record in the database.

    3.Wrap in Start/Stop Test:

    Execution and Assertion. 

    Assign your mock, wrap the future method call inside Test.startTest() and Test.stopTest(), and assert that the record was updated successfully.

    Apex 

     

    @isTest

    private class NewProjectHandlerTopUpTest {

    // 1. Mock class for HTTP callouts

    public class MockHttpResponseGenerator implements HttpCalloutMock {

    public HTTPResponse respond(HTTPRequest req) {

    HttpResponse res = new HttpResponse();

    res.setHeader('Content-Type', 'application/json');

    res.setStatusCode(200);

    // Construct JSON response matching the parser requirements

    res.setBody('{"state": "Success", "resBody": "{\\"id\\": \\"12345\\"}"}');

    return res;

    }

    }

    @isTest

    static void testNewProjectHandlerTopUp() {

    // Create test record to satisfy update operation

    Bid_Review_Request__c testReq = new Bid_Review_Request__c(

    Name = 'Test Project'

    // Add required fields for Bid_Review_Request__c here

    );

    insert testReq;

    Map<String, String> recordMap = new Map<String, String>{

    'ID' => testReq.Id,

    'Name' => 'Test Project'

    };

    // Set mock callout

    Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());

    Test.startTest();

    // Calling the future method

    YourClassName.newProjectHandlerTopUp(recordMap, '{"test":"json"}', 'destination', 'WBS123');

    Test.stopTest(); // Future method executes here

    // Assertions to verify the record was updated

    Bid_Review_Request__c updatedReq = [SELECT WBS_Project__c FROM Bid_Review_Request__c WHERE Id = :testReq.Id];

    System.assertEquals('12345', updatedReq.WBS_Project__c, 'The WBS Project code should be updated successfully.');

    }

    }

    (Note: Replace YourClassName with the actual name of the Apex class containing your future method).

0/9000

I am trying to disable by using autocomplete="Off" but its now working can anyone help with this i am using this under lightning record edit form

 

#Sales Cloud  #Service Cloud  #Marketing Cloud  #Analytics  #Nonprofit  #Trailhead  #New Releases  #Integration  #AppExchange

1 answer
  1. Yesterday, 6:57 AM

    Hi Vikrant, autocomplete="off" isn't supported directly by lightning-input-field because it doesn't expose the underlying <input> element's autocomplete attribute. 

    If you need to control autocomplete, you can use lightning-input instead of lightning-input-field and set: 

    <lightning-input

    type="text"

    autocomplete="off"

    name="myField">

    </lightning-input>

      

    If you need to keep lightning-record-edit-form and lightning-input-field, you generally can't reliably disable the browser's autocomplete through the component attribute. 

      

    If you can share which field you're trying to disable autocomplete for and what browser you're testing in, I can suggest a more specific workaround. 

     

0/9000

error it is showing is:-

You are missing information needed by the page you have attempted to access. If you believe this is an error, please refresh your screen. If the error persists, please <a href="javascript:openPopupFocusEscapePounds('/HelpAndTrainingDoor?body=%2Fhelp%2Fswitchuserwait.jsp%3FcssJump%3D%2Fsserv%2Fcaseedit.jsp&loc=support', 'Help', 1024, 768, 'width=1024,height=768,resizable=yes,toolbar=yes,status=yes,scrollbars=yes,menubar=yes,directories=no,location=yes,dependant=no', false, false);" title="report (New Window)">report</a> it to our Customer Support team and provide the URL of the page you were requesting as well as any other related information.

Unit:-Prepare your organization

 

#Sales Cloud  #Service Cloud  #Trailhead  #New Releases  #AppExchange

1 answer
  1. Yesterday, 6:52 AM

    Hi Nisha, this can happen if there is an issue with the Classic Email Template folder page or if the required permissions aren't available.  

     

    Please check that you have the “Manage Public Classic Email Templates” permission (or the appropriate email template management permissions) and that you have access to the Classic Email Templates folder functionality.  

     

    Also try refreshing the page or accessing Setup → Classic Email Templates → Create New Folder again from a fresh Salesforce session.  

     

    If the same error persists after verifying the permissions, I recommend creating a Salesforce Support case and providing the URL and exact error message, since the error itself suggests Salesforce Support investigate the page request 

0/9000

Hi All,

 

As we can give Account, Opportunity and Case Access through Account Team, does this Override the Profile, Field or Record Level Access? Suppose someone already having access through Profile, Field or Record Level to Edit a Account or Opportunity Record but in Account Team access is given as Private for Read Only So it should not take Account Team access right?

 

Also If Someone is given access to Opportunity from an Account's Account Team as Private and From that Opportunity's Oppty Team the access is Given as Read/Write, Which it will be imply to?

 

Thank you

5 answers
  1. Dec 28, 2023, 4:50 PM

    The easiest way to look into access rights is that Account teams and Opportunity teams can only open up access.

    If your organization-wide default access for accounts and opportunities is set to Private and if you give team members access to an individual opportunity, those users gain read-only access to accounts on the opportunity. Conversely, if you remove a user’s access to an individual account, the user is removed from opportunity teams related to the account.

     

    However, it will not work the other way around. If the org-wide default access for accounts and opportunities is set to Public, the user will have edit rights to both account and opportunity. I.e. you are not able to restrict access with account and opportunity teams, only open it up.

     

    It is worth testing but I do believe that for example if your org-wide defaults are set to public, you will not even have the private option on the account or opportunity teams.

0/9000

I need to create a formula field that updates a checkbox after verifying Company's value. I couldn't complete creating a formula field as it throws an error that the limit is 5000 characters. I want to query many company values and update the checkbox. Can someone please suggest an alternative to achieve this functionality?

 

Can I create a trigger or apex class? 

 

#Sales Cloud #Analytics #Automation #Integration Would creating that be affected by character limits as well?

1 answer
  1. Sep 17, 2:07 PM

    Hi SidParnam,

    If you're maintaining a long list of company names in a formula, I wouldn't recommend moving the same large IF/OR logic into Apex. Apex doesn't have the formula field's 5,000-character limit, but hard-coding a large company list makes the solution difficult to maintain.

    A better approach would be to store the company values as configuration:

    • Create a Custom Metadata Type with the company name and the checkbox value.
    • Use a before-save Record-Triggered Flow to look up the company and set the checkbox.
    • If you need more complex processing or a very large dataset, Apex can also query the configuration and update the record.

    This way, adding or removing a company doesn't require changing and redeploying your formula/Apex code. 

     

    If you share approximately how many company values you have and whether the checkbox needs to update immediately when the Company field changes, we can suggest the simplest implementation. 

0/9000

I see from this idea exchange item that you can send an email alert when I

 

#Sales Cloud #Service Cloud #Trailhead #Automation #New Releases new note is created a record, but the link is broken. Does anyone know how to accomplish sending email alerts when someone adds a new note? 

 

https://ideas.salesforce.com/s/idea/a0B8W00000GddhfUAB/emailchatter-notifications-on-notes-and-attachments-updates

1 answer
  1. Sep 17, 2:02 PM

    Hi Bob,

    If you're referring to Enhanced Notes, you can automate this using the ContentNote and ContentDocumentLink objects. 

     

    One approach is to use a record-triggered Flow on ContentDocumentLink to detect when a note is linked to the record, then send an email notification to the appropriate users. 

     

    Keep in mind that ContentDocumentLink is used for linking the Note to records, so you'll need to determine the linked record and recipients before sending the notification. 

     

    If you share which record you want to notify users about (Account, Contact, Opportunity, etc.) and whether you're using Enhanced Notes, I can suggest the exact Flow configuration. 

0/9000

Hello! I'm exploring the idea of creating a fully populated "ideal Salesperson" user. From Leads, to Quotes, to Sales calls, I'd like to populate this "ideal Salesperson" to show how the team can leverage all aspects of our salesforce org and find value in following processes.  What is the best way to deploy this type of user? Ideally I wouldn't have to use a live license for this user. Any ideas or recommendations are appreciated!   

2 answers
  1. Mar 2, 4:54 PM

    How would this proposed "Dummy Salesperson" User actually be used within your org?  

     

    One difficulty with not assigning an "Active" License to the User is that's it is extremely difficut to assign records to an "Inactive" User, if this User is to be used for Testing/Training purposes.   

     

    Say for example you wanted to do a Sales User Training Session and take off your Sys Admin Hat, and do a live demo of "Dummy Sales User" creating a new Lead, logging Activity on the Lead, adding them to a Campaign, updating their Campaign Member Status, Nurturing, Quailifying and Converting the Lead into an Account, Contact, Opportunity, Closing the Opportunity, etc...  

     

    All of that will be impossible if the Dummy User is inactive.   

     

     

     

0/9000

Hi,

I am currently facing an issue in our production environment related to the generation of a Proforma Invoice and saving the corresponding PDF to the 'Notes and Attachments' section.

In our Order object, when the stage is set to 'Invoice,' we trigger the generation of a Proforma Invoice by clicking the 'Generate Invoice' button. The PDF rendering is handled through an Aura component named 'generateOrderContract,' which embeds a Visualforce page called 'ProformaInvoiceNew.'

While this functionality works seamlessly in our sandbox environment, post-deployment to production, an error occurs when attempting to save the rendered PDF to attachments. The error displayed on the UI is as follows: "Error: An internal server error has occurred. Error ID: 189341393."

The code is:

 

            PageReference pdfPage = new PageReference(pageurl);

            Blob pdfData;

            if (!Test.isRunningTest()) {pdfData = pdfPage.getContentAsPDF();}

            else {

                pdfData = Blob.valueOf('This is a test.');

            }

In this getContentAsPDF(); is not working(not getting any value).   

Please help me with some solution. 

1 answer
  1. Sep 16, 8:44 PM

    Hi Prachi,

    Since getContentAsPDF() is working in the sandbox but failing in production, I would first compare the Visualforce page and user/configuration between the two environments. 

     

    Please check:

    • The ProformaInvoiceNew Visualforce page is deployed and accessible in production.
    • The running user has the required access to the Visualforce page, Apex class, and objects/fields referenced by the page.
    • Any custom settings, custom metadata, permissions, or referenced records used by ProformaInvoiceNew are available in production.
    • Check whether the pageurl being passed to PageReference is valid in production.
    • Review the debug log for the user executing getContentAsPDF() to see whether the Visualforce page is throwing an exception while being rendered.

    You can also test the Visualforce page directly in production using the same user to determine whether the issue is with the page rendering or with the attachment creation. 

     

    Since Salesforce is returning an Internal Server Error with an Error ID, if the page works directly and all permissions/configuration are correct but getContentAsPDF() still fails, I would recommend creating a Salesforce Support case and providing the Error ID (189341393) and the debug logs so Salesforce can investigate the server-side error.

0/9000

Hi Folks,  

Many of you will be attending Dreamforce and completing certifications there — so if anyone happens to have a spare exam pass for a certification you don't plan to use, I'd love to take it off your hands! I'd really appreciate your help. 😁  

 

#Certifications  #Sales Cloud

1 answer
  1. Eric Burté (DEVOTEAM) Forum Ambassador
    Sep 16, 8:25 PM

    Hello @Maria Sabiniewicz, I guess that this kind of pass is personal, as the vouchers are. 

    Please have a look at the following ways to try to get one, instead, but I guess you already know it :

    Good luck ! 

    Eric

0/9000

I'm getting stumped on this. Org wants to create a push notification for overdue tasks. I have done it using a record-triggered flow with 7 days and 2 days as being notifications email to say Task is about to be due. Could it just be a push notification which stays in Salesforce, notification sent to the notification bell once daily . 

 

#Trailhead Challenges  #Trailhead  #Salesforce Admin  #TrailblazerCommunity  #Sales Cloud  #Formulas

5 answers
  1. Sep 16, 4:35 PM

    Hi @Scott Holmes

     

    Yes, you can check the formula syntax directly in Flow Builder. Formula resources are created within the Flow, so you won't find their syntax in Object Manager.

    To view the syntax:

    1. Open your Flow in Flow Builder.
    2. Go to the Manager tab.
    3. Under Resources, select your Formula resource (Due in 7 Days / Due in 2 Days).
    4. Open the formula to view or edit its syntax.

    For example:

    Due in 7 Days:

    {!$Record.ActivityDate} = TODAY() + 7

    Due in 2 Days:

    {!$Record.ActivityDate} = TODAY() + 2

    You can also review Salesforce's formula documentation for additional functions and syntax. 

     

    Hope this helps!  

     

     If you find this response helpful, please mark it as the Accepted Answer, as it may also help other Trailblazers facing a similar issue. 😊 

0/9000