You need to sign in to do that
Don't have an account?
Matt Eck 15
Append @ Mention to FeedComment
Hey All,
I am currently hitting an issue editing a FeedComment as it is inserted. What I would like to do is append an @ mention to the comment so the Case Owner will be alerted. We have a support portal and we can not rely on customers to use the @ mention functionality but without this, the support team is not being alerted that a new comment has been added.
Here is my current trigger handler:
Currentlythis "works" to add an @ mention by adding literally "@<OwnerId.Name>" but this is just plain text and not actually notifying the owner.
I have found several articles stating I need to utilize the Connect API such as this one: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm
However, all the articles I find are stating how to create a net new comment with an @mention but I want to append an @mention to an existing comment as it comes in. Is this possible or am I not approaching this the correct way?
I am currently hitting an issue editing a FeedComment as it is inserted. What I would like to do is append an @ mention to the comment so the Case Owner will be alerted. We have a support portal and we can not rely on customers to use the @ mention functionality but without this, the support team is not being alerted that a new comment has been added.
Here is my current trigger handler:
public class FeedCommentTriggerHandler { public static void appendAlert(List<FeedComment> comments){ Map<Id,Case> caseMap = new Map<Id, Case>(); for(FeedComment comment : comments){ if(comment.ParentId.getSObjectType().getDescribe().getName() == 'Case'){ caseMap.put(comment.ParentId, new Case()); } } if(!caseMap.isEmpty()){ caseMap = new Map<Id, Case>([SELECT Id, OwnerId, Owner.Name FROM Case WHERE Id IN :caseMap.keySet()]); for(FeedComment comment : comments){ if(caseMap.containsKey(comment.ParentId)){ comment.CommentBody += ('\n@' + caseMap.get(comment.ParentId).Owner.Name); } } } } }
Currentlythis "works" to add an @ mention by adding literally "@<OwnerId.Name>" but this is just plain text and not actually notifying the owner.
I have found several articles stating I need to utilize the Connect API such as this one: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm
However, all the articles I find are stating how to create a net new comment with an @mention but I want to append an @mention to an existing comment as it comes in. Is this possible or am I not approaching this the correct way?
>> https://developer.salesforce.com/blogs/engineering/2015/06/preserving-mentions-triggers.html
As mentioned in the above link, the problem I am adding below for quick reference, can you try checking this article once?
Let me know if it helps you and close your query by marking it as the best answer so that it can help others in the future.
Thanks.