You need to sign in to do that
Don't have an account?
Anton Yoganathan
Hyper link in apex class
Hi,
how can i bring out something similar to
"
<a href="Https://www.google.com">Search</a>
"
in the following code.
trigger chatterfeed on Feedback__c (after update) {
for(Feedback__c feed:trigger.old)
{
FeedItem post = new FeedItem();
post.ParentId = 'Some id';
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ Feed.id;
String stringURL = '<a href='+fullFileURL+' >Test</a>/>';
post.Body =stringURL;
insert post;
}
for which i get a post with a link like below and clicj=king on it should direct to me to the link on the href.
"
Test
"
'String stringURL = '<a href='+fullFileURL+' >Test</a>/>'; this does no work..
how can i bring out something similar to
"
<a href="Https://www.google.com">Search</a>
"
in the following code.
trigger chatterfeed on Feedback__c (after update) {
for(Feedback__c feed:trigger.old)
{
FeedItem post = new FeedItem();
post.ParentId = 'Some id';
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ Feed.id;
String stringURL = '<a href='+fullFileURL+' >Test</a>/>';
post.Body =stringURL;
insert post;
}
for which i get a post with a link like below and clicj=king on it should direct to me to the link on the href.
"
Test
"
'String stringURL = '<a href='+fullFileURL+' >Test</a>/>'; this does no work..
You can use LinkUrl field of FeedItem sObject
i.e.
Regards
Virendra
Thanks for the reply...
The post.LinkUrl will just post the url... my intention is not to post a link. my intention is to get a hyperlink in the post body. so that when i click on the hyper link it redirects me to the link given in href link.
String stringURL = '<a href='+fullFileURL+' >Test</a>/>';
by hyper link i mean : Test
by link i mean :URL.getSalesforceBaseUrl().toExternalForm()+ ' / ' + Feed.id;
Thanks,
Anton
Like in the above html code if i click on Search , it will take me to google.com... Some thing like this.
Now i understand what you want.
but i think you cannot use rich HTML in chatter posts. You'll need to include the full URL text as part of the post.
and if you find a way then tell me also (i am also searching for that ).
Regards
Virendra
version7.7@hotmail.com (mailto:version7.7@hotmail.com)
You can use HTML by adding post.isRichText = true; Make sure your api version is 35.0 or above on your Apex code metadata setting.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feeditem.htm - see isRichText on this page