I would ask if I can disable the Chatter mention in a standard way or I must use a custom solution as a Trigger.
3 Answers
At the moment, Apex Triggers is the only option AFAIK to restrict mention on user/group level.
Suggestion: Use hierarchical custom setting to make the user/profile configurable.
There is [would be] a feature available for groups:
I wrote two triggers, on FeedItem and FeedComment.
FeedItem Trigger:
trigger MentionFeedItem on FeedItem (before insert, before update) {
List<User> listUserPlatform = [SELECT ID, Name FROM User];
List<String> listNameUserPlatform = new List<String>();
for(User u : listaUserPlatform) {
listNameUserPlatform.add('@'+u.Name);
}
for(FeedItem f : Trigger.new) {
Boolean nameFinded = false;
for(Integer i=0; i < listNameUserPlatform.size() && !nameFinded; i++) {
if( f.Body.contains(listNameUserPlatform.get(i)) ) {
nameFinded=true;
f.addError('You can\'t use mention');
}
}
}
FeedComment trigger:
trigger MentionFeedComment on FeedComment (before insert, before update) {
List<User> listUserPlatform = [SELECT ID, Name FROM User];
List<String> listNameUserPlatform = new List<String>();
for(User u : listaUserPlatform) {
listNameUserPlatform.add('@'+u.Name);
}
for(FeedComment f : Trigger.new) {
Boolean nameFinded = false;
for(Integer i=0; i < listNameUserPlatform.size() && !nameFinded; i++) {
if( f.CommentBody .contains(listNameUserPlatform.get(i)) ) {
nameFinded=true;
f.addError('You can\'t use mention');
}
}
}
}
Thanks :)
To basically disable mentions in Salesforce Communities specifically:
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.