I want to add a hyperlink to the body of a feeditem with apex code. I tried to with class of EncodingUtil.urlEncode but it is not work. So I`d like to know how shall I do. Thx!
//Adding a Link post FeedItem post = new FeedItem(); post.ParentId = oId; //eg. Opportunity id, custom object id.. post.Body = 'Enter post text here'; post.LinkUrl = 'http://www.someurl.com'; insert post;
You can refer a field named "type" in Feeditem that decides the body.You have following choices
The type of FeedItem you can use is LinkPost—a URL posting on a feed