Search Content

Featured Content

WhitePapers


How to Buy a Phone System

Considering a new phone system for your business? The Phone System Buyer's Guide from VoIP-News provides you with all of the information you need to make a more informed decision. The Guide helps you...Read More


Which CMS Is Right For Me?

If you're wondering which CMS is the right one for your organization, this comprehensive guide will take you through the various options available, detailing the pros and cons of each. Download...Read More


Oracle Magazine

Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest...Read More


Sales Force Automation Comparison Guide

Businesses of all sizes can benefit by automating all aspects of their sales processes with an SFA (Sales Force Automation) solution. But due to the sheer number of features that most SFA solutions...Read More




View All Whitepapers

Sidebar Summary using Visualforce

About a year ago, I posted about the Sidebar Summary. The Sidebar Summary exists in the Salesforce.com sidebar and displays the counts of some important queries. The counts are also hyperlinks to a view or report representing that query. Its a very handy thing to have in your sidebar and I use it all the time for my own work. However, because its an s-Control, it runs a little slow. In fact, it ran slow enough to make me uncheck the user interface option Show Custom Sidebar Components on All Pages.

I changed it into a Visualforce page with a custom Apex controller and now it runs super fast and I am able to keep the Show Custom Sidebar Components on All Pages option turned on and see it on every page I go to. Theres a bit of hardcoding in here, but it gets the job done pretty well. Bye bye s-Control.

Visualforce

The Page is almost all raw HTML. The only dynamic thing in there are the count values. Each one retrieves the value from a specific get method in the controller. If you like the queries I use, then the only thing youll need to confirm are the URLs that get linked to. The first 2 go to Views in my Org and the last 2 go to Reports in my Org. Youll need to change those URLs.

I named the VF Page SidebarSummary.


<apex:page controller="VFController_Sidebar_Summary"
sidebar="false" showHeader="false" standardStylesheets="true">
<style type="text/css" media="all">
body{
margin: 0;
padding: 0;
color: #000000;
background-color: #E8E8E8;
}
#DIV_Container {
background-color: #F3F3EC;
}
</style>
<div id="DIV_Container">
<table>
<tr><td><em>Unread Leads</em>: </td>
<td><a href="/00Q?fcf=00B30000005JhsT" target="_parent">
<b>{!UnreadLeads}</b></a></td></tr>
<tr><td><em>Leads - Not Contacted</em>: </td>
<td><a href="/00Q?fcf=00B30000005Jhru" target="_parent">
<b>{!NotContactedLeads}</b></a></td></tr>
<tr><td><em>Oppty - Next 30 Days</em>: </td>
<td><a href="/00O30000001aEHV" target="_parent">
<b>{!Next30DayOppty}</b></a></td></tr>
<tr><td><em>Oppty - Past Due</em>: </td>
<td><a href="/00O30000001aEHV" target="_parent">
<b>{!PastDueOppty}</b></a></td></tr>
</table>
</div>
</apex:page>

Apex

The controller has a method for each query to be run. Each query is a count() query and returns an Integer. At the end is a really lame Test method, but it does get 100% of the code covered. I am certain the code works, so I didnt do too much with the Test method. Salesforce just requires the code to be tested.


public class VFController_Sidebar_Summary {

public Integer getUnreadLeads() {
return [
select count() from Lead
where IsConverted = False
AND IsUnreadByOwner = TRUE
];
}

public Integer getNotContactedLeads() {
return [
select count() from Lead
where IsConverted = False
AND Status = 'Open - Not Contacted'
];
}

public Integer getNext30DayOppty() {
return [
select count() from Opportunity
where IsClosed = False
AND (CloseDate = Next_N_DAYS:30 OR CloseDate = TODAY)
];
}

public Integer getPastDueOppty() {
return [
select count() from Opportunity
where IsClosed = False
AND CloseDate < TODAY
];
}

static testMethod void testVFController_Sidebar_Summary() {
Test.setCurrentPageReference
(new PageReference('Page.SidebarSummary'));
VFController_Sidebar_Summary controller =
new VFController_Sidebar_Summary();
Integer i1 = controller.getUnreadLeads();
Integer i2 = controller.getNotContactedLeads();
Integer i3 = controller.getNext30DayOppty();
Integer i4 = controller.getPastDueOppty();
}

}

Homepage HTML Component

I created a component for the Narrow side and put the following HTML into the editor. Essentially, you create an IFRAME and embed the VF page into it. I found a (unsupported) trick on the forums to remove the developer bar from a page. Just add ?core.apexpages.devmode.url=1 to the URL. This will turn off development mode when that page is rendered. This is important for this little iFrame page on the sidebar. From what Ive gathered, this hack is not supported and could change at any time.

The code below should work for you. The only thing you might need to change is the Page URL if you didnt name your page SidebarSummary and the height of it.


<iframe src="/apex/SidebarSummary?core.apexpages.devmode.url=1"
frameborder="0" height="100" width="100%"></iframe>

Let me know what you think.


Related Marketing Intelligence Software Articles

ebizQ Discussion on SOA & Cloud Computing


The eBizQ site recently hosted a discussion is based on JP Morgenthal's feature article, Differing Views on SOA & Cloud Computing, and the question, which seemed to cause a bit of disagreement between the old "gray hair" and new "newbie" schools...

Read more about ebizQ Discussion on SOA & Cloud Computing...

Gmail Outage Raises Concerns for Small Business


Latest Gmail Outage Raises Concerns for Small Business Sometimes, your greatest assets can become costly liabilities. Google's remarkable success and rapid growth over the past few years may have set the bar too high for customer expectations of...

Read more about Gmail Outage Raises Concerns for Small Business...