What was I thinking? Using something as complicated as a hijacked (from the Console) Task view was bound to have problems when creating an Activities tab.
Let’s restate our goals:
- Create a tab that will show Activities, using the Enhanced Lists view.
- Don’t have two rows of tabs at the top of the page.
Question: Is there any way to make a view and to specify that we don’t want to see the Sidebar AND the Tabs?
Answer: YES. The answer is Visualforce!
We will use Visualforce’s iframe tag to fool the UI into thinking that it’s displaying a URL other than the one it thinks it’s displaying.
Step 1: Enable Developer mode. Then create a Visualforce page. I called mine Activities, so the URL is [instance]/apex/Activities
<apex:page standardController="Event" tabStyle="Event" sidebar="false" showHeader="false" name="Activities" label="Activities">
<apex:panelGrid width="100%" columns="1" id="exitLink" bgcolor="#EFEFEF">
<apex:outputLink value="/home/home.jsp" id="homeLink">Exit this view</apex:outputLink>
<apex:iframe src="/007" height="900px" scrolling="true" id="theIframe"/>
Notes on the code:
- If you remove the height tag, it defaults to 100%, but that’s in relation to the number of rows in your list. So the Sidebar may be cut off if you have too few rows. Stick with a standard height. I chose 900 because I assume that most screens are 1280×1024 resolution, minimum.
- I used 007 (the object ID for Activities), but I could have used 00T (Tasks).
- If you click on anything in the page, the URL will remain /apex/Activities. This is because you are technically working within an IFrame. This is the reason for the Exit link.
- The code calls the standard stylesheet so that it comes up in Salesforce’s preferred Arial font instead of Times New Roman.
- I created a table with one column for the Exit link so that I could color the background of the link the same as the top of a Salesforce page; this is purely for cosmetic reasons.
Now we’ll create a Visualforce Tab:
Setup -> Create -> Tab
Scroll to the bottom of the page
New Visualforce Tab
Select the Activities page from the picklist
Choose an icon (I liked the whistle) but keep in mind that it doesn’t matter because we’re using the Events controller, so the page will have the Events green color.
Finish the wizard, and you’re done!
Here are my favorite parts of the setup:
- It uses Visualforce.
- A standard controller means no Apex classes are required.
- The code can be used in any org as-is.
- We use a full-sized IFrame to fool the Visualforce page into thinking that it’s displaying something other than a fully customized VF view!