Skip to content

Instantly share code, notes, and snippets.

@douglascayers
Created January 14, 2017 21:37
Show Gist options
  • Save douglascayers/729b2fde5cec0b5161256967e66ba342 to your computer and use it in GitHub Desktop.
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.
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;
@douglascayers
Copy link
Author

douglascayers commented Jan 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment