We have 1 Community that both internal and external users of the company have access to. We've created 2 separate Salesforce Profiles for each:

Internal Community User
External Community User

Currently, our External users can @mention internal users when posting a question to the Community forum (Chatter).

Is there a way to turn off/restrict the external user's ability to @mention people?

Thanks in advance for your help!



3 Answers 3


You can do one thing. Write trigger on feeditem and get body of message then you can check if string contains you group name and profile is not matched. Then add error message. using trigger.New[0].addError();

Source link

Also check this out may be this will help User and Group @Mentions—Visibility

enter image description here


You can achieve this as follow:

  • Create a trigger on FeedItem
  • Create a map of Id and user of outside users
  • Now loop on All new feedItems and do something like following trigger code:

    trigger ChatterFeedItemTriggerAI on FeedItem (after insert) {

    List<Incident__c> toUpdate = new List<Incident__c>();
    Set<Id> usersIdSet= New Set<Id>();
    //Collect all ParentIds    
    for(FeedItem record : trigger.New){
    Map<Id,User> outSideUserMap = New Map<id,User>([SELECT Id FROM User WHERE Id IN:usersIdSet AND Profile.Name = 'outside User']);
    for(FeedItem record : trigger.New){
        ConnectApi.FeedElement feedItem = ConnectApi.ChatterFeeds.getFeedElement(record.NetworkScope, record.Id);
       List<ConnectApi.MessageSegment> messageSegments = feedItem.body.messageSegments;
       for (ConnectApi.MessageSegment messageSegment : messageSegments) {
            if (messageSegment instanceof ConnectApi.MentionSegment && outSideUserMap.containsKey(record.InsertedById)) {
                record.addError('You are not authorized to add mention!');


This is not tested code, so Please try and change if anything wrong.

Let me know if you have any doubt about it.


Yes, to remove the option for external community members from mentioning (or viewing after typing '@' symbol) other fellow members in Salesforce Communities:

1.) In Setup ---> Sharing Settings, Set the Default External Access "Users" to private.

2.) In Setup ---> Sharing Settings, Uncheck both "Portal User Visibility" and "Community User Visibility" checkboxes.

Salesforce Communities restrict mentions members visibility mentioning

Read more here: https://help.salesforce.com/articleView?id=networks_user_sharing.htm&type=5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .