3

I am trying to create a chatter post using an APEX trigger, and I'm almost there. I've gotten to this point:

ConnectApi.ChatterFeeds.postFeedItem(null, ConnectApi.FeedType.News, 'me', feedItemInput, null);

Which successfully creates the post that I want it to create, including an @mention. However, it posts it to the context user's ('me') chatter feed, whereas I want it to post to the feed of the record that set off the trigger.

Is it possible to set the 'parentId' field like you used to be able to with FeedItem? If so, how should I go about doing this? If not, is there an alternative?

Thanks!

1 Answer 1

13

Figured it out! Replace 'me' with the ID of the record to post to, and change ConnectApi.FeedType.News to ConnectApi.FeedType.Record, and you're good to go!

3
  • Awesome, great find. I know there is a waiting time, but make sure you come back and mark your answer when you can (I believe it is in two days). Upvoted! Commented Feb 14, 2013 at 21:31
  • were you able to have the mention appear before and the text follow later? I dont think that control we have. Commented Jun 8, 2018 at 11:24
  • @ChiragMehta Sorry but I haven't worked on Salesforce in years, so I won't be of much help on this. Good luck! Commented Jun 8, 2018 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .