• IndiaSforce
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

As Admin can not prevent directly some profile based user to add comment. I have develope small trigger which can help you for this validation.

 

trigger RistrictUser on FeedComment (Before Insert) 
/*This trigger will restirct user to add comment on chatter*/
{
for(FeedComment FC: trigger.new)
    {
    /*Following Code will get Current User information*/
    User u = [SELECT id,ProfileId,Profile.Name  FROM User WHERE id = :UserInfo.getUserId()];

    /*We are going to restrict user from 'Non-Chatter Users' profile */
        if(u.Profile.Name == 'Non-Chatter Users')
        {
            FC.adderror('You can not post comment'); //You can Customize the error message here 
        }

    }
}/*EOF*/

 

 

Let me know your feedback

As Admin can not prevent directly some profile based user to add comment. I have develope small trigger which can help you for this validation.

 

trigger RistrictUser on FeedComment (Before Insert) 
/*This trigger will restirct user to add comment on chatter*/
{
for(FeedComment FC: trigger.new)
    {
    /*Following Code will get Current User information*/
    User u = [SELECT id,ProfileId,Profile.Name  FROM User WHERE id = :UserInfo.getUserId()];

    /*We are going to restrict user from 'Non-Chatter Users' profile */
        if(u.Profile.Name == 'Non-Chatter Users')
        {
            FC.adderror('You can not post comment'); //You can Customize the error message here 
        }

    }
}/*EOF*/

 

 

Let me know your feedback