function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PrajarikamPrajarikam 

I need to diasble users to create , share, poll files in chatter object.

Hi everyone how can i do it . I think we need to use homepage layout, but how to do it . Can anyone help me on that.

 

 

Regards,

Praveen.

Vinit_KumarVinit_Kumar

Hi Praveen,

 

You can write a Trigger on FeedItem object to control the access of users.A sample code is below :-

 

Trigger controlpost on FeedItem (before insert,before update){

 

String check = null;
    
    List<User> uids = [SELECT id FROM User];
    List<CollaborationGroup> gids = [SELECT id,CollaborationType FROM CollaborationGroup];

   
    for(FeedItem fid: trigger.new){
        for(User uid: uids){
            if(uid.id == fid.ParentId){
                check = 'cp';
            }
        }
    }

    for(FeedItem fid: trigger.new){
        for(CollaborationGroup gid: gids){
            if(gid.id == fid.ParentId && gid.CollaborationType == 'Public'){
                check = 'cpg';
            }
       }
    }
            
    for(FeedItem fid: trigger.new){
        if((check == 'cp') ){
           if((fid.Type == 'TextPost')&&(sharecommentscp == False)){          
               fid.addError('Sorry, Posting Comments to Profiles are not allowed due to security reasons!');                 
           }

          

else if((check == 'cpg') ){
        System.debug(fid.type + ' this is type ' + sharelinkscpg + ' this is custom setting');
           if((fid.Type == 'TextPost')&&(sharecommentscpg == False)){          
               fid.addError('Sorry, Posting Comments to Public Groups are not allowed due to security reasons!');                 
           }
            }   
        
        
    }
    
    
     
    
}