function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BPeddleBPeddle 

Adding a link to a FeedPost

I suspect I am over looking something simple.  I am trying to insert a Link into a Feed Post and can't seem to do it.  Example:

 

 

FeedPost post = new FeedPost();
post.Body = 'Hey  now! <a href="http://google.com">Google</a>';
post.parentid = UserInfo.getUserId();
insert post;

 

FeedPost post = new FeedPost();

post.Body = 'Hey  now! <a href="http://google.com">Google</a>';

post.parentid = UserInfo.getUserId();

insert post;

 

Is this possible?

Best Answer chosen by Admin (Salesforce Developers) 
BPeddleBPeddle

This will solve my problem for now.  Thanks!

 

FeedPost post = new FeedPost();
post.Type = 'LinkPost';
post.Title = 'View Job Posting - Accountant';
Post.LinkURL = 'http://www.google.com';
post.Body = 'New Job Available - Check it out!';
post.parentid = UserInfo.getUserId();
insert post;

FeedPost post = new FeedPost();

post.Type = 'LinkPost';

post.Title = 'Google';

Post.LinkURL = 'http://www.google.com';

post.Body = 'This is the body, hey now!';

post.parentid = UserInfo.getUserId();

insert post;

 

All Answers

bob_buzzardbob_buzzard

FeedPost has a LinkUrl property that you can use for this.  I've also been able to add links using the raw URL, but I don't think anchor tags will work as that requires something  to render the HTML.

BPeddleBPeddle

This will solve my problem for now.  Thanks!

 

FeedPost post = new FeedPost();
post.Type = 'LinkPost';
post.Title = 'View Job Posting - Accountant';
Post.LinkURL = 'http://www.google.com';
post.Body = 'New Job Available - Check it out!';
post.parentid = UserInfo.getUserId();
insert post;

FeedPost post = new FeedPost();

post.Type = 'LinkPost';

post.Title = 'Google';

Post.LinkURL = 'http://www.google.com';

post.Body = 'This is the body, hey now!';

post.parentid = UserInfo.getUserId();

insert post;

 

This was selected as the best answer