Created
May 9, 2017 03:14
-
-
Save douglascayers/5240ebe1f9fef8ed66ac6fa8a80bdd43 to your computer and use it in GitHub Desktop.
Proof of concept automatically add "Recommendation" link to Chatter Posts. Inspired by https://success.salesforce.com/0D53A000036B7Ai
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * For any Chatter post that is not a 'LinkPost' then add a FeedAttachment | |
| * that links to system to integrate with, such as a third-party system to capture recommendations. | |
| * | |
| * https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedattachment.htm | |
| * | |
| * Inspired by https://success.salesforce.com/0D53A000036B7Ai | |
| */ | |
| trigger FeedItemTrigger on FeedItem (after insert) { | |
| List<FeedAttachment> feedAttachments = new List<FeedAttachment>(); | |
| for ( FeedItem fi : Trigger.new ) { | |
| if ( fi.type != 'LinkPost' ) { | |
| feedAttachments.add( new FeedAttachment( | |
| feedEntityId = fi.id, | |
| type = 'Link', | |
| title = 'Recommend', | |
| value = 'www.your-recommendation-site.com?fid=' + fi.id | |
| )); | |
| } | |
| } | |
| if ( feedAttachments.size() > 0 ) { | |
| insert feedAttachments; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment