You need to sign in to do that
Don't have an account?
LouShropshire
Chatter FeedItem Style/ Type in Apex
How do I create a Chatter Post that looks like this?
What I want to do is, have a trigger that calls a function to create a chatter post when a new contact is created. I want it to look like the image below. Right now, I have a trigger on 'Contact' that calls a function, but I'm not sure of how to create a Chatter FeedItem that looks like this.
Is there a certain FeedItem Type that will do this?
Or is there a way for me to add style to the FeedItem?
These types of feed items are automatically created when you use Publisher Actions to "quick create" a record.
You can use the QuickAction namespace in Apex to create records, which will automatically generate a feed item like the one in your screenshot. Here are the docs:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_namespace_QuickAction.htm
The SOAP API also lets you use quick actions to create records:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_performquickactions.htm
In your example, if you create a new contact through the normal way on the Contacts tab, you won't be able to write a trigger that produces a feed item like the one you want. Those feed items are system-generated. You'd have to create a "New Contact" publisher action and use either the Publisher UI or the API to create the contact, which would generate the feed item.