+ Start a Discussion

using @mention in trigger


I have a trigger which is firing on feed item which will capture the opp id and account id on posting a chatter posr on opportunity

the trigger is working fine and the update is correctly happening

my issue is when i type @user and post something , the user gets gradeout in black  where the email is not fired to respective users

whereas in other object it is highlighted in blue correclty

let me know whats the issue and how to handle it in my trigger


trigger FeedItemTrigger on FeedItem (before insert,before update) {
    set<id> parentAccountIds = new set<id>();

    for(FeedItem fdItem : trigger.new){
        String idStr = fdItem.Parentid;

   Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);
    for(FeedItem fdItem : trigger.new){
        Opportunity parentopportunity = oppty.get(fdItem.Parentid);

        String chatterBody = fdItem.Body;
        fdItem.Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id;


Kindly help me on this regard

Thanks in Advance

Azhar Aziz GAzhar Aziz G
Hey - We could not mention user through apex directly. This only be done by Connect API. Please review the documentaion for help.