You need to sign in to do that
Don't have an account?
Michael M
How to customize ConnectApi linkInput appearance to look like task
Hello, I am create a chatter via ConnectApi in Apex, and I am using a linkInput. The issue is that it just looks like a blue box, when we want (need :) it to look like when a task is logged (because we are triggert this connectApi post after inserting a task via apex.) Here is the snippet of code, what it looks like, and what we want it to look like:
Snippet:
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ tsk.id;
linkInput.url = fullFileURL;
linkInput.urlName = tsk.type_referral__c;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput;
How it looks:
How we want it to look:
Snippet:
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ tsk.id;
linkInput.url = fullFileURL;
linkInput.urlName = tsk.type_referral__c;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput;
How it looks:
How we want it to look:
Micheal, I have checked internally too, this is not available right now.
You can raise an Idea for it.
All Answers
// Define the FeedItemInput object to pass to postFeedElement
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
feedItemInput.subjectId = 'me';
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
textSegmentInput.text = 'Check out this link.';
// The MessageBodyInput object holds the text in the post
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
messageBodyInput.messageSegments.add(textSegmentInput);
feedItemInput.body = messageBodyInput;
// The FeedElementCapabilitiesInput object holds the capabilities of the feed item.
// For this feed item, we define a link capability.
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
linkInput.url = 'https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_input_link_capability.htm';
linkInput.urlName = 'Doc link';
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput;
// Post the feed item.
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
For further reference check this official article (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_feed_element_content.htm).
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
1) The blue element (in picture in my original post) should be the green checklist element instead
2) The full URL does not appear on the display
3) There is the "view more details" option included
Are these 3 possible?
public class ReferralInlineActivityHandler {
public static void CreateActivity(Id refId){
Lead ref = [ Select id, Activity_Type__c,Activity_Notes__c From Lead Where Id =: refId];
Task tsk = new Task(
Type_Referral__c = ref.activity_type__c,
whoid = ref.id,
Completed_Date__c = date.today(),
notes__c = ref.Activity_Notes__c,
ActivityDate =date.today(),
tasksubtype = 'Task',
from_inline_activity__c = true
);
insert tsk;
id userId = UserInfo.getUserId();
user u = [select id, name from user where id = : userId];
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
ConnectApi.EntityLinkSegmentInput entityLinkSegmentInputActivity = new ConnectApi.EntityLinkSegmentInput();
entityLinkSegmentInputActivity.entityId = tsk.Id;
messageBodyInput.messageSegments.add(entityLinkSegmentInputActivity);
ConnectApi.TextSegmentInput textSegmentInput1 = new ConnectApi.TextSegmentInput();
textSegmentInput1.text = ' - ';
messageBodyInput.messageSegments.add(textSegmentInput1);
ConnectApi.EntityLinkSegmentInput entityLinkSegmentInputUser = new ConnectApi.EntityLinkSegmentInput();
entityLinkSegmentInputUser.entityId = u.id;
messageBodyInput.messageSegments.add(entityLinkSegmentInputUser);
ConnectApi.TextSegmentInput textSegmentInput2 = new ConnectApi.TextSegmentInput();
textSegmentInput2.text = ' created a task';
messageBodyInput.messageSegments.add(textSegmentInput2);
ConnectApi.LinkCapabilityInput linkInput = new ConnectApi.LinkCapabilityInput();
String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm()+'/'+ tsk.id;
linkInput.url = fullFileURL;
linkInput.urlName = tsk.type_referral__c;
ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
feedElementCapabilitiesInput.link = linkInput;
feedItemInput.capabilities = feedElementCapabilitiesInput;
feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
feedItemInput.subjectId = refId;
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);
}
}
I think so check this once,
https://salesforce.stackexchange.com/questions/227124/custom-icons-from-static-resource-on-lightningicon-not-working
2) The full URL does not appear on the display
For this check the pagelayout and permissions once.
Still you are not seeing means have to compare the debug logs for both working and non working scnerio.
3) There is the "view more details" option included.
I don't know this.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Micheal, I have checked internally too, this is not available right now.
You can raise an Idea for it.