Book Image

Salesforce CRM Admin Cookbook

By : Paul Goodey, Paul Goodey GP
Book Image

Salesforce CRM Admin Cookbook

By: Paul Goodey, Paul Goodey GP

Overview of this book

Salesforce CRM is a market-leading customer relationship management (CRM) application that is accessed over the Internet. It is a proven system which helps to manage large volumes of information across an organization and also improves communication between departments for exceptional customer service. The CRM application is available for the management of sales projections and orders, marketing plans, knowledge management, service and support, partner relationships, and data analytics. The application greatly enhances a company's sales performance, improves customer satisfaction, and provides a robust customer relationship management system for an organization. For optimum performance of the system, there are a lot of things for you as the Salesforce administrator to know and tackle, but there isn't a single book which focuses on the administrative aspect of Salesforce CRM. "Salesforce CRM Admin Cookbook" enables you to instantly extend and unleash the power of Salesforce CRM. It provides clear, comprehensive instructions along with detailed screenshots and code. Whether you are looking for solutions to enhance the core features or are looking for ideas for advanced customization techniques, this book will provide you with immediate, practical, and exciting real-world recipes. This book provides practical, step-by-step instructions that cover the use of hidden features, advanced user interface techniques, solutions for process automation, and data and systems integration in detail. This book guides you through interesting topics spanning a variety of functional areas. Recipes are provided that cover data quality and automation, approval and workflow processing, solutions to increase productivity, and the integration of Salesforce CRM with external tools and applications, such as Google and Microsoft Outlook. "Salesforce CRM Admin Cookbook' provides practical, step-by-step instructions to deliver enhanced functionality and extend the power of Salesforce CRM.
Table of Contents (17 chapters)
Salesforce CRM Admin Cookbook
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Showing Opportunity Sales Stages descriptions on the home page


The Opportunity Sales Stages configured in a Salesforce organization are important for pipeline and performance measurement. The stages should be clearly described and communicated to the sales team and across the business. In this a recipe we will describe the stages in Salesforce and make these descriptions available on the home page.

Getting ready

Carry out the following steps to add sales stages descriptions:

  1. Navigate to the home page components setup page by going to Your Name | Setup | Customize | Opportunities | Fields | Stage.

  2. Click on Edit on the Stage Name.

  3. Enter text in the Description field.

    Note

    Now continue to add descriptions for all your sales stages by following the steps above.

How to do it...

Carry out the following steps to create an Apex class to show Opportunity Sales Stages descriptions on the home page:

  1. Navigate to the home page components setup page by going to Your Name | Setup | Develop | Apex Classes.

  2. Click on New.

  3. Paste the following code ( as shown in the following screenshot):

    // Controller code for Help Sales Stage VisualForce Page Handler
    public class clsHelpSalesStages{
      // This is a public getter method and returns a list of Opportunity Sales Stages 
      // the method is called from the Visualforce page
      public List<OpportunityStage> getSalesStages(){
        // This is a SOQL query to retrieve a list of matching Opportunity Sales Stages
        // The SELECT clause returns the fields: MasterLabel, IsClosed, IsWon, ForecastCategory, 
        //     ForecastCategoryName, DefaultProbability, Description
        // The WHERE clause (WHERE IsActive = true) filters the query so that only Active 
        //     Opportunity Stages are returned
        // The the ORDER BY clause (ORDER BY SortOrder ASC sorts the list of Opportunity Stages
        //     in ascending order using the SortOrder field 
        // the standard Sort Order
        List<OpportunityStage> lstOppStage = [ SELECT MasterLabel, 
                               IsClosed,
                               IsWon, 
                               ForecastCategory, 
                               ForecastCategoryName, 
                               DefaultProbability, 
                               Description
                        FROM OpportunityStage
                        WHERE IsActive = true
                        ORDER BY SortOrder ASC ];
        return lstOppStage;
      }
      // This is a test method - The test methods must provide at least 75% code coverage
      // test methods are required to deploy Apex to a production environment
      public static testMethod void testMyController(){
        clsHelpSalesStages objOppStage = new clsHelpSalesStages();
        List<OpportunityStage> lstOppStageTest = objOppStage .getSalesStages();
        // This is an assertion to ensure that Opportunity Sales Stages are returned.
        System.assert( lstOppStageTest.size() > 0 );
      }
    }
  4. Click on Save.

Carry out the following steps to create a Visualforce page to show Opportunity Sales Stages descriptions on the home page:

  1. Navigate to the home page components setup page by going to Your Name | Setup | Develop | Pages.

  2. Click on New.

  3. Enter vfpHelpSalesStages in the Label field.

  4. Accept the default vfpHelpSalesStages in the Name field.

  5. Paste the following code (as shown in the following screenshot):

    <apex:page controller="clsHelpSalesStages" tabStyle="Opportunity" showHeader="false" sidebar="false">
    <apex:form >
    <apex:sectionHeader title="Sales Stages Description. Date: {!NOW()}"/>
    <apex:pageBlock title="">
    <apex:pageMessages ></apex:pageMessages>
    <apex:pageBlockTable value="{!SalesStages}" var="s" rendered="{!NOT(ISNULL(SalesStages))}">
    <apex:column >
    <apex:facet name="header">Name</apex:facet>
    <div style="background-color:{!CASE(s.ForecastCategoryName,'Closed','maroon','Omitted','#FFA07A','Commit','green','Funnel','blue','gray')}; 
    color:{!CASE(s.ForecastCategoryName,'Omitted','black','white')}">
    {!s.MasterLabel}
    </div>
    </apex:column>
    <apex:column value="{!s.DefaultProbability}"></apex:column>
    <apex:column value="{!s.Description}"></apex:column>
    <apex:column value="{!s.ForecastCategoryName}"></apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
    </apex:page>
  6. Now set security for the required profiles in your organization (this is required for every user profile that you wish to view the sales stage descriptions).

  7. Navigate to the home page components setup page by going to Your Name | Setup | Customize | Home | Home Page Components.

  8. Click on New.

    Note

    The New button is found by scrolling down the page to the Custom Components section.

  9. Click on Next (on the Understanding Custom Components splash screen if shown). The Next button is found on the Understanding Custom Components splash screen (this page is only shown if the Don't show this page again checkbox has not previously been checked), as in the following screenshot:

    Here, we are presented with the Step 1. New Custom Components page.

  10. Enter the name of the custom component in the Name field. Enter the text Opportunity Sales Stages.

  11. Select the HTML Area option from the Type options list.

  12. Click on Next.

  13. Ensure that the option Wide (Right) Column is selected within the Component Position option list.

    Note

    You are unable to change this setting after the component is created.

  14. Check the Show HTML checkbox.

    Note

    The above step is important! Locate and check the Show HTML checkbox as shown in the following screenshot:

  15. Paste the following code:

    <iframe style="width: 100%; height: 400px;" src="/apex/vfpHelpSalesStages" frameBorder="0"></iframe>
  16. Click on Save.

    Note

    We have created our Opportunity Sales Stages custom home page component but we are not finished yet. We now need to add the custom home page component to a home page layout.

  17. Navigate to the home page components going to Your Name | Setup | Customize | Home | Home Page Layouts.

  18. Determine which home page layout to place the component on and click on Edit. Here we are editing the home page layout named DE Default.

    We are presented with the Step 1. Select the components to show page.

  19. Check the Opportunity Sales Stages checkbox in the Select Wide Components to Show section, as shown in the following screenshot:

  20. Click on Next.

  21. Move the Opportunity Sales Stages to the top position in the Wide (Right) Column using the Arrange the component on your home page. section, as shown in the following screenshot:

  22. Click on Save.

How it works...

By adding the description for the sales stages, the Visualforce and Apex reads the data directly from within Salesforce and so, regardless of whether the sales stage descriptions change or even the sales stages themselves change in the future, the content is always up-to-date.

Users can then see the description, that you would have set, for each of the opportunity stages in the organization on the Visualforce page without having to create dummy opportunities and look at the available stage names.

Salesforce does not natively support the embedding of Visualforce pages into the home page, hence the need to create this HTML custom component. Within this component we are using the <iframe> HTML tag we are able to insert the rendered output of a specified Visualforce page.

You can see how this appears on the home page in the following screenshot:

There's more...

When entering HTML and JavaScript code into the HTML editor section (in step 2 of the component's wizard) you must ensure that the code is valid.

Note

Pay particular attention to the displayed warning message:

Please ensure that the HTML code entered below is valid, well formed HTML. Poorly written HTML in this component may cause the entire Home tab to appear incorrectly

There are a maximum of 20 custom components that can be added to a home page layout.