Making an Activity Tab in Salesforce with Apex and Visualforce

Activities are made up of Tasks and Events. Tasks are an activity that need to be done, but not necessarily at a specific time (like a phone call, or an email). Events are scheduled for an exact day and time (like a meeting). Activities in Salesforce (in Lightning at least) are typically shown in the activity timeline supported on accounts, cases, contacts, leads, opportunities, etc.

There does already exist a Task tab, and you can see Events via your calendar - thankfully through the Powers of Apex we can join them in one place.It’s a two step process - lets break it down.

Step One: Create a Visualforce page that display activities:

Creating anything on Salesforce? We start in the Setup tab.

Search for Visualforce Pages and create a new page.

Choose a label, name and add a description.

In the Visual Markup section is where we add our Apex code - thankfully for this it is very simple.

Code:<apex:page ><apex:enhancedList type="Activity" height="600" /></apex:page>

Apart from the <apex:page> tag that defines the start and end point we only have three parts to this very straight forward code.

  • enhancedList- This tag tells Salesforce to display the information as a list.

  • Type - This is where you select your object to show. In our case this is the Activity tag to show both Tasks and Events

  • Height - This tag defines the height of the list.

Press save and you’re halfway there!

Step Two: Create a Visualforce Tab

Once again - creating something new so back to the Setup tab.Search for Tabs and create a new Visualforce Tab. Select your previously made Visualforce page and fill out the rest.

Choose the user profiles, and applications where the Tab will be shown.With the tab being made your mission is over - visit the final product - Tasks and Events in one single location.

See you on the Trail.

Previous
Previous

The Decision Element: Salesforce Flow Builder 101

Next
Next

Turn Off the Lights! with Dark Mode for Salesforce Lightning