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
pavan Kumar.vpavan Kumar.v 

CHATTER POST VISIBILITY

HI ALL,
I HAVE WRITTEN A TRIGGER SO WHENEVER CERTAIN USER IS POSTING A MESSAGE IN CHATTER , THE CHAT POST SHOULD BE CHANGED TO 'ALL USER'

if(feedItemRecord.CreatedById == '005f4000004zl8mAAA' || feedItemRecord.CreatedById == '0056N000001QahNQAS ') { feedItemRecord.Visibility = 'AllUsers'; feedItemRecord.Status = 'Published'; }

BUT ITS NOT WORKING, CAN ANYONE GUIDE ME ON THIS PLASEA
AnkaiahAnkaiah (Salesforce Developers) 
Hi Pavan,

You need to write after trigger ifyou want to use the createdbyid. System fields are not available in the before trigger.
try with below code.
trigger statusupdate on FeedItem (After insert) {
    
    List<feeditem> feediteminsert = new  List<feeditem>();
    
    for(FeedItem fi:trigger.new){
        if(fi.createdbyid=='0056N000001QahNQAS' || fi.createdbyid=='005f4000004zl8mAAA' ){
            feeditem f = new feeditem();
            f.id =fi.id;
            f.status='Published'; 
            f.visibility = 'All users';
           feediteminsert.add(f) ;
        }
    }
    
    insert feediteminsert;

}

If this helps, Please mark it as best answer.

Thanks!!​​​​​​​