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:
- Setup | Develop | Apex Classes
- Click “New”.
- Copy all the FeedRevisionController code, paste it into the Apex Class text box, and click “Save”.
- [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:
- Setup | Develop | Pages
- Click “New”.
- Give the page a Label (e.g. “ChatterEditHistory”).
- Copy all the ChatterEditHistory code, paste it into the Visualforce Markup text box, and click “Save”.
- 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.
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.