You need to sign in to do that
Don't have an account?
Ricardo Palma 16
How convert an Account name to a hyperlink in a chatter post using ConnectApi in Apex.
I'm creating a chatter feed using ConnectApi.
I'm posting some text but also I need to create a link to the Account record, baically is the account name is ABC Company I want the user to be able to click the name to go to the Account record. Currently I have the url to the but what I need is click on the account name.
Here is part of the code.
message = 'This Account has requested cancellation. Please review and take action on ' + accMap.get(urec.AccountId).Name + ' ' + System.Url.getSalesforceBaseURL().toExternalForm() + '/' + accMap.get(urec.AccountId).Name ;
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
ConnectApi.TextSegmentInput textSegmentInputLine = new ConnectApi.TextSegmentInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
textSegmentInput.text = message + twolines;
messageBodyInput.messageSegments.add(textSegmentInput) ;
feedItemInput.body = messageBodyInput ;
I'm posting some text but also I need to create a link to the Account record, baically is the account name is ABC Company I want the user to be able to click the name to go to the Account record. Currently I have the url to the but what I need is click on the account name.
Here is part of the code.
message = 'This Account has requested cancellation. Please review and take action on ' + accMap.get(urec.AccountId).Name + ' ' + System.Url.getSalesforceBaseURL().toExternalForm() + '/' + accMap.get(urec.AccountId).Name ;
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
ConnectApi.TextSegmentInput textSegmentInputLine = new ConnectApi.TextSegmentInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
textSegmentInput.text = message + twolines;
messageBodyInput.messageSegments.add(textSegmentInput) ;
feedItemInput.body = messageBodyInput ;
use ConnectApi.LinkCapabilityInput or ConnectApi.LinkSegmentInput Class to link ur account in chatter
reffer this link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_input_link_capability.htm
Regards,
vinaykumar s