6

For any individual user, he can click on MY SETTINGS. Navigate to CHATTER. Then EMAIL NOTIFICATIONS. There under Personal section, deselect "Follows Me" to stop receiving email notifications when someone follows him.

Now my requirement is to deselect the same through code as default for all Chatter Users.

Can someone please let me know if that is achievable through Apex class, data load or any other way?

9

It can be done. There is field called UserPreferencesDisableFollowersEmail which actually store the Follow me option data for the user.

so if you want to do this via trigger or class just put the below code snippet, it will work :-

//Select List of user for which Follows Me option. you can put where logic for selective users
List<User> lst_User = [Select Id,UserPreferencesDisableFollowersEmail from User];
List<User> lst_updated = new List<User>();//list of user which will be updated

if(!lst_User.isEmpty() && lst_User.size()>0){
    for(User us : lst_User){
        us.UserPreferencesDisableFollowersEmail = true;//it should be true if you want to unchecked the Follows Me
        lst_updated.add(us);    
    }   
}

if(!lst_updated.isEmpty() && lst_updated.size()>0){
    update lst_updated; //updated the user 
}

i have done this in my developer Org,it is working fine. It should solve your purpose.

2
  • 1
    User[] users = [SELECT Id FROM User]; for(User record: users) { record.UserPreferenesDisableFollowersEmail = true; } update users; – sfdcfox Apr 19 '17 at 12:21
  • if(!list_update.isEmpty() && list_updated.size() > 0) appears to check for the same thing twice, since size() will never return a negative number. Also, modifiable user preferences can be found on the User class documentation - developer.salesforce.com/docs/atlas.en-us.api.meta/api/… – IllusiveBrian Apr 19 '17 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.