Quantcast
Viewing latest article 21
Browse Latest Browse All 68

Preserving @mentions in the FeedItem trigger edit

I have written before insert trigger that concatenates Case Subject to the Chatter post when it is posted from the case record. But when I do that, @ mentions are getting stripped from the chatter post and the post is getting posted as a normal text, because of which the @mentions aren't getting any notifications.

Below is the apex helper class that I have written for the above functionality.

public with sharing class FeedItemHelper {    Map<String, String> caseSubMap = new Map<String, String>();    Set<String> chatterParentIdList = new Set<String>();    public FeedItemHelper() {}    public void caseSubjectConcat(List<FeedItem> feedItemList) {        for(FeedItem feedPar : feedItemList) {            chatterParentIdList.add(feedPar.ParentId);        }        List<Case> caseList = [SELECT Id,                                     Subject,                                     CaseNumber                                     FROM Case                                     WHERE Id In :chatterParentIdList];        List<FeedItem> caseFeedItems = [SELECT Id,                                            body,                                            ParentId                                            FROM FeedItem                                            WHERE Parent.Type = 'Case'];        if(caseList.size() > 0) {            for(Case caseOne : caseList) {                caseSubMap.put(caseOne.Id, caseOne.CaseNumber +' : '+caseOne.Subject);            }        }        for(FeedItem feedOne : caseFeedItems) {            feedOne.body = caseSubMap.get(feedOne.ParentId) +' : '+ feedOne.body;        }    }}

Can someone please let me know how the @mentions can be preserved while editing the body of the FeedItem record? Thanks in advance.


Viewing latest article 21
Browse Latest Browse All 68

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>