[SalesForce] Create Chatter post with mix of HyperLinks and text in the Body (in Apex code)

How to create a chatter post in the body I want to add Links in between. (in Apex code)

its not complete link or complete plain text. I am looking at mix of both

Example Chatter post –

just has call with John[link to contact here] and closed opportunity name[link to opportunity ]

Update – its not simple chatter post with LinkUrl (the one suggested in reply is very easy)

I need final chatter post to look like as follows – (basically with hyperlinks)

just has call with John and closed opportunity name

Best Answer

So, I haven't actually tried this, but here's what I would try first:

FeedItem myPost = new FeedItem();
myPost.Parentid = object.Id; //user's Id I'm assuming
myPost.body = 'Text here http://www.internets.com more text http://www.theinternets.com';
insert myPost;

Obviously, you'd have to get the Id of the object you're posting to and the links to the contact and opportunity.

Related Topic