Created
January 14, 2017 21:37
-
-
Save douglascayers/729b2fde5cec0b5161256967e66ba342 to your computer and use it in GitHub Desktop.
Example creating FeedItem in Apex and setting the author. Note, requires the "Insert System Field Values for Chatter Feeds" permission.
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
FeedItem item = new FeedItem( | |
parentId = UserInfo.getUserId(), // where to post message | |
createdById = '005j000000Bz31U', // author to impersonate | |
body = '<p><b>FeedItem</b> supports <i>rich text</i> but not @ mentions:</p> @[0F9j00000008TNc] @0F9j00000008TNc {0F9j00000008TNc} @{0F9j00000008TNc}', | |
isRichText = true | |
); | |
insert item; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Snippet used on my blog post: https://douglascayers.com/2017/1/15/chatter-bot-for-feeds/
FeedItem documentation: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm