Pages

Wednesday, December 18, 2013

Can we sort Salesforce Activity History ?

Can we sort Salesforce Activity History? Until Summer '14 release, user cannot sort related list manually (including Activity History), and admin also not able to change the default sort. Activity History is always sort by Due Date (or ActivityDate in API name) in descending order. It will not consider the created date or modified date in the sort order.

Here is a clear example of Activity History with the same Due Date:



Then, we edit item 2 and 3, we change the Due Date for item 2 to 8/23 and item 3 to 8/25, it will be re-sort with Due Date desc.



Remember Due Date is just a date, no time stamp, so if you have multiple activity history created at the same date, it will not order by created or last modified date time

But, we have a workaround, here we go:

1. Create Custom Button in Task
Setup - Customize - Activities -  Task Buttons, Links, and Actions
Click "New Button or Link", then select Behavior, Content Source and URL as screenshot below:
/007?id={!Account.Id}&rlid=RelatedHistoryList <-- this is for Account

2. Add Custom Button into Account or Contact or other object page layout
Edit the Layout, scroll to Related Lists and look for Activity History.
Click 'Related List Properties' icon, then click + in Buttons sections, add the button to right panel

3. Save the Page Layout and Done.

User will see new button added to 'Activity History' related list. When user click the button, it will open new page where user will be able to sort by any fields.


In Winter '15 release, Salesforce introduce sorting Activity History by Last Modified Date in ascending order, but caused some inconsistency and this has been reverted the changes made in Winter 15.