Activity › Forums › Salesforce® Discussions › How to get “mentionSegmentInput.id” in Salesforce Chatter?
-
How to get “mentionSegmentInput.id” in Salesforce Chatter?
Posted by shradha jain on August 8, 2018 at 7:46 AMHow to get “mentionSegmentInput.id” in Salesforce Chatter?
shariq replied 7 years, 7 months ago 3 Members · 2 Replies -
2 Replies
-
Hello Shradha,
ID of the user or group to mention. To mention a user, use either id or username. You can’t include both.
To mention a group, you must use id.
-
This reply was modified 7 years, 8 months ago by
Forcetalks.
-
This reply was modified 7 years, 8 months ago by
- [adinserter block='9']
-
Hi,
I this code will explains thing you want –
List<AccountTeamMember> list_objAcctmem = [SELECT UserId, AccountId, IsDeleted, User.Name FROM AccountTeamMember WHERE AccountId =: objCase.AccountId LIMIT 25];
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
//ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
textSegmentInput.text = ‘Casenumber ‘ +objCase.CaseNumber+’ with the status ‘+objCase.Status+’ has breached SLA aggrement hours’;
messageBodyInput.messageSegments.add(textSegmentInput);
// Mention a group.
if(list_objAcctmem.size() > 0)
{
for(AccountTeamMember objAcctmem : list_objAcctmem )
{
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
mentionSegmentInput.id = objAcctmem.UserId;
messageBodyInput.messageSegments.add(mentionSegmentInput);
}
}
feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
// Use a record ID for the subject ID.
feedItemInput.subjectId = objCase.Id;
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(null, feedItemInput, null);Hope this helps.
Log In to reply.