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
Michael MMichael M 

@mention users in task

Hello, I need to be able to @mention users in a task. Our tasks get posted to chatter. Is there a way to do this?
Best Answer chosen by Michael M
VinayVinay (Salesforce Developers) 
Hi Michael,

You can give a try but I believe this won't work and connect api will post a brand new.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Michael,

You can enable feed tracking on Tasks and that will allow you to Chatter on tasks.

Quick Find ---> Feed Tracking--->Task object---> Enable feed tracking.

Thanks,
Vinay Kumar
AnudeepAnudeep (Salesforce Developers) 
Hi Michael, 

When your task gets posted to the chatter, you have an option to @mention your users using the comments section. Note that we can only @Mention someone in Posts and Comments. When you write/edit a post, enter @ followed by the first few letters of the person or group name. You can @mention someone as long as they have access to that record 

User-added image
Michael MMichael M
Thank you. I was thining that if we add a custom text area field to Activity, and display that in the task, if users write @User Name, I can have a trigger on Tasks that queries users with that name, and then use ConnectApi to @mention those users. Do you think this would work? If so, is there a way to make that Connect-api-post a comment to the task, and not a brand new post?
AnudeepAnudeep (Salesforce Developers) 

Yes you can writer a trigger on task and Post a Feed Element with a Mention to @mention your user

You can give the Id of the user you want to mention as well
mentionSegmentInput.id = '005RR000000Dme9';
Hope this helps

Anudeep
VinayVinay (Salesforce Developers) 
Hi Michael,

You can give a try but I believe this won't work and connect api will post a brand new.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm

Thanks,
Vinay Kumar
This was selected as the best answer