function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sfdc007sfdc007 

using @mention in trigger

Hi,

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

 
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;

        if(idStr.startsWith('006')){
           parentAccountIds.add(idStr);
        }
        
        
    }
    
   Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);
   if(oppty.size()>0){
    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.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_static_methods
Thanks,