One of the most interesting new features in Salesforce Summer ’13 is Chatter Actions. This feature lets you build out specific functionality that’s accessible directly from the Chatter feed. An example of this might be to give a user the ability to create a Contact from their Chatter feed. An Action can be set to a global context which makes it accessible from the User’s Chatter feed on the Home and Chatter tabs, or it can be set to an object-specific context which makes it accessible only from a particular object’s Chatter feed. For instance, you might create an object-specific Action on the Account object that lets the user create a new Contact, thus implying the relationship between the Contact and the Account.
Salesforce obviously anticipated the creation of new records would be a primary use-case so they baked in special support for it. Actions are separated into two groups – Create Actions and Custom Actions. Create Actions are fairly straightforward so I think Custom Actions are the more interesting of the two. To illustrate the usefulness of Custom Actions I’ll walk through an example below.
Use Case: Users create Notes related to Contacts, and they want a way to search through and find the Notes that contain a word or phrase. We’ll create a Custom Action that is object-specific to the Contact object.
Step 1: Enable Publisher Actions for your org. This may seem obvious but I wasted a decent amount of time before I figured this out. Go to Setup > Customize > Chatter > Enable Publisher Actions.
Step 2: Create the Visualforce page and Controller as shown below. I’ve named the page “SearchNotesAction” and the controller “SearchNotesController.” You’ll also need to grab the SearchHelper class which is a utility I wrote to help make SOSL searches easier. You’ll find that code here in one of Kevin O’Hara’s(@kevino80) github repositories. Feel free to contribute any of your useful Apex utilities.
Step 3: Create the Action. Go to Setup > Customize > Contacts > Buttons, Links, and Actions > New Action. Select Custom Action and the Visualforce page from Step 2. See image below.
Step 4: Add the Action to the Chatter Feed on the Contact page layout. Keep in mind that because this Action is specific to the Contact object we’ll need to do this from the Contact page layout. Go to Setup > Customize > Contacts > Page Layouts > select your page layout. Find the Action created in Step 3 and drag it onto the Chatter Feed section. See image below.
The only thing left to do now is test it out. Go to any Contact and add a few Notes to it. The new Custom Action is accessible from the record’s Chatter feed. Depending on where you placed it on the page layout you might have to click the “More” drop-down link. See image below.
I hope this example has been helpful as you explore Chatter Actions. As always, I look forward to any feedback.