Pages

Wednesday, December 18, 2013

Can we sort Salesforce Activity History?

Can we sort Salesforce Activity History? Until Summer '14 release, users cannot sort related list manually (including Activity History), and admin also not able to change the default sort. Activity History is always sorted 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 the 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 the right panel

3. Save the Page Layout and Done.
User will see a new button added to 'Activity History' related list. When the user click the button, it will open a new page where the 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.


5 comments:

  1. Hi,

    Is there a way to acheive the same custom list button functionality for a Visualforce page in Lightning?

    Currently if I use the RelatedHistoryList it is giving me an error message that says

    'You don't have access to this record. Ask your administrator for help or to request access.'

    ReplyDelete
    Replies
    1. hi, sorry to reply that I do not know the answer, I think SFSE is better place for that kind of questions.

      Delete
  2. Hey Johan, This solution perfectly working in classic mode, Could you please help me to achieve same with lightning experience.

    ReplyDelete

Page-level ad