2

I have a chatter feed publisher component at 2 places(topics page and article page) in a community and whenever user posts something, I'm writing a trigger code on FeedItem object to auto at mention a public chatter group(topic discussions). For example, if I post 'test' , trigger automatically appends @topic doscussions to the test and updates the feed item post. It's working as expected from article page but from topic page , I'm getting the error

ConnectApi.ConnectApiException: Mentioned group does not exist

It's really odd because its the same code that was working for one feeditem record but not for the other. Any insights into this would help!

String communityId = '0DB5O0000000***';

// Get the last feed item created by the context user.
List<FeedItem> feedItems = [SELECT Id FROM FeedItem WHERE id = '0D55O000000XTai***'];//feed item posted on topic : erroring out
//List<FeedItem> feedItems = [SELECT Id FROM FeedItem WHERE id = '0D55O000000XVF9***'];//feed item posted on article : working fine

String feedElementId = feedItems[0].id;

    ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
    ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
    ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
    ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
    messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
    mentionSegmentInput.id = '0F95O0000000I7bSAE'; // topic discussion : public group

    textSegmentInput.text = 'This is my edited post1.';
    messageBodyInput.messageSegments.add(textSegmentInput);
    messageBodyInput.messageSegments.add(mentionSegmentInput);
    feedItemInput.body = messageBodyInput;

    ConnectApi.FeedElement editedFeedElement = ConnectApi.ChatterFeeds.updateFeedElement(communityId, feedElementId, feedItemInput);

1 Answer 1

1

I figured it out. if in case anyone face the issue- create the groups inside the community to be able to mention them from a community. More details here https://success.salesforce.com/answers?id=90630000000Zj8TAAS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .