How to Display Revision History in Chatter

By

Have you ever needed to implement something in Salesforce that didn’t have a button click solution? I recently helped out some of our #AwesomeAdmins at Salesforce so that a Chatter feature I worked on could be enabled internally. If it helped out admins at Salesforce, maybe it’ll help you too. So let’s walk through it!

In Summer ’15, we delivered the ability to edit your Chatter posts and comments. There currently isn’t a way to see the detailed history of your edits in the Salesforce UI. The only way to access it is via the API, which is the area I work in.

Revision history may not seem that important when you’re correcting a typo, but for companies that have compliance requirements, it’s essential. If you use Chatter as a system of record, you need to know exactly what changed, who changed it, and when it changed. If you work for a publicly traded company, you may have external auditors who require the complete revision history for SOX compliance.

Salesforce (the company) is no exception. When our finance department raised concerns about enabling the Chatter editability feature on our own Salesforce org, I realized that we could fulfill the compliance requirements by using our APIs and VisualForce.

My solution was a programmatic one, not a declarative one — sorry, ButtonClick Admins! I won’t go into the coding details here. Instead, I’ll show you how to copy the code to your org and use it to view the history of a thread. (Note: I’m also planning to put it on the AppExchange as a free download soon.)

What it looks like

If you have a Chatter thread with some edits, like this:

The VisualForce page lets you paste in the URL of the thread to view all the edits to the feed items and comments:

You can grant access to the users in your org who need to use it. The page only displays the history of threads that a user has access to.

Step 1: Add the Apex classes

The Apex class is called FeedRevisionController and can be copied from my GitHub repository. The easiest way to add it to your org is:

  1. Setup | Develop | Apex Classes
  2. Click “New”.
  3. Copy all the FeedRevisionController code, paste it into the Apex Class text box, and click “Save”.
  4. [Optional] Repeat the above steps for the FeedRevisionControllerTest class if you need unit test coverage (e.g. if you need to deploy from Sandbox to Production).

Step 2: Add the VisualForce page

Similarly, you need to add the VisualForce page:

  1. Setup | Develop | Pages
  2. Click “New”.
  3. Give the page a Label (e.g. “ChatterEditHistory”).
  4. Copy all the ChatterEditHistory code, paste it into the Visualforce Markup text box, and click “Save”.
  5. Click “Preview” to try out the page.

Step 3: Create a tab

Now you can create a VisualForce tab and configure the users who can access it.

What’s next?

Now that you’ve got a VisualForce page that can display Chatter editing history, you should test it out to make sure it suits your needs. Identify the other users who need to use the page, and give them a demo. One gotcha that your users might run into is finding the URL of a Chatter thread: the easiest way is to click on the timestamp of the post.

I hope this solution will make your life as an admin easier. Also, if you’re the kind of admin who likes to dabble with code, feel free to tinker and send me a pull request on GitHub if you can make the page even better.

How to Create an Admin Page Layout

In case you haven’t noticed, but Salesforce Admins are special. As a Salesforce Admin you have to be special because you are the first one called on if there is a problem. Let’s take a simple problem, but one I run into more often than not- like data being populated in a field and troubleshooting […]

READ MORE
how-to-deal-with-the-salesforce-insufficient-privileges-error

How to Deal with the Salesforce Insufficient Privileges Error

Editor’s note: This is a popular blog post, so we’ve updated it with the latest information and resources on September 8, 2020. In my experience, the email or phone call starts out something like this: “I clicked on this [insert link, account, etc. here] and I’m getting an ‘Insufficient Privileges’ error… I know I should […]

READ MORE

5 Tips for Staying Productive While You’re on Vacation

It’s summertime—and while the benefits of a cloud-based system include the ability to stay connected to your business and respond rapidly from anywhere in the world, constant connectivity can also cut into your quality time on the beach. Eager to kick back, but worried you’ll fall behind? Don’t stress. Just follow my 5 easy tips […]

READ MORE