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:stylesheet value="/dCSS/Theme2/default/common.css"/>
<apex:panelGrid width="100%" columns="1" id="exitLink" bgcolor="#EFEFEF">
<apex:outputLink value="/home/home.jsp" id="homeLink">Exit this view</apex:outputLink>
</apex:panelGrid>
<apex:iframe src="/007" height="900px" scrolling="true" id="theIframe"/>
</apex:page>
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
Name: Activities
Label: Activities
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!
frasuy says
Nice solution. Having the Activities list view exposed is so much better than being buried in the calendaring component on the Home tab.
Do you know if there is a way to accomplish the same thing without the iframe? Having the dual sidebars to navigate up and down on the page is ok but not great from a user experience.
Thoughts?
David Schach says
Great request! In fact, I finished up a pure VF Tasks page a few days ago. Stay tuned for the code. After I’ve done that, I’ll create and publish an Events page as well.
stanleyh says
Seems two issues for my use: 1. From the “customer home”, if I click “Account”, the URL is not like normal; 2. Then, from “Account”, if I click “Home”, it go back to normal View, instead of your Activity view.
Thanks for sharing!
David Schach says
Yes, this is true. Please keep checking back – we’ll have the pure VF code up as soon as possible.
James says
Just Create a VF page with a meta redirect to “/007” this will elimiate any iframe needed.
David Schach says
That is true now, but when the post was written, Event & Task did not support enhanced list views.
Manish Panchal says
Nice solution friend. Great Thanks.