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
mirarunmirarun 

Is there a way to override SHARE button ?

Hello folks,

Is there a way to override the 'Share' button on the chatter window ? Im trying to find a way to enable chatter for our Org and make it available for only certain profiles. Looks like there is no straight forward way to do this. This being the case, if I can override the share button or if I can find a way to write a trigger on 'SHARE' , I can display user friendly warnings to the profiles that are not allowed to use Chatter.

 

Appreciate your thoughts folks.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
cloudcodercloudcoder

This will not execute a FeedItem trigger because, when adding a post from your User's home page you are actually updating the user status which exists on the User object. You could add a trigger to the User object and check for changes on User.userStatus.

 

All Answers

cloudcodercloudcoder

You can not currently override the share button, but as of Spring 11 you can write triggers on feed items which should be able to achieve the functionality you are looking for.

mirarunmirarun

Thanks for the response cloudcoder. But if I understand correctly, the trigger on FeedItem gets executed only upon a change in the feed tracking ? I tried and the new FeedItem trigger is not getting executed when a post is shared. Thoughts ?

mirarunmirarun

CloudCoder, to add: Im expecting the trigger to fire when someone text is posted on the chatter window in the home page.

cloudcodercloudcoder

Yes you can add a trigger on before insert for example, and use the addError message to return an error message to the user. eg, 

 

 

trigger MyCoolTrigger  on FeedItem (before Insert) {
    
    for (FeedItem f : trigger.new)
    {
        //do some logic
        {            
            f.addError('You messed up!');
        }
    }
}

 

 

bvramkumarbvramkumar

Hi cloudcoder

 

I am having a trigger on FeedItem Insert. I am able to test it and it works fine. Now i am having hard time to write the test coverage for this trigger. I tried to insert a FeedPost with all possible feed types like "UserStatus" etc... But could not achieve anything. Can you please help me with some clues or workarounds.

 

Thanks

Vishnu

 

cloudcodercloudcoder

Can you share your trigger code, and test code? I can then respond with some pointers, suggestions

ChrisctChrisct

Quinton,

 

I'm having the same issue as mirarun. I have code that runs after insert of FeedItem...this appears to work regardless of what a user is posting against (e.g. account, contact, custom object). The only exception to that is when a user posts to his or her homepage. The trigger does not appear to fire in this case.

 

Would you have any insight on the issue?

 

Thanks,

 

Chris

cloudcodercloudcoder

This will not execute a FeedItem trigger because, when adding a post from your User's home page you are actually updating the user status which exists on the User object. You could add a trigger to the User object and check for changes on User.userStatus.

 

This was selected as the best answer
ChrisctChrisct

Thanks, Quinton. I got that to work. Much appreciated.

mirarunmirarun

Thank you Quinton. It worked :)

Seema ASeema A

Can you explain how u did that ?

ChrisctChrisct

 

For my specific case, I needed to look at the user object before update:
trigger UserStatusBefore on User (before update) {

 for (User u : trigger.new) { }

}

 

The field that is updated is on the user object when one posts to the home page is: currentStatus

 

Seema ASeema A

Hey thax for reply . But still there is a problem , I want to write a simple trigger on chatter post. Whenever i will post comment on chatter, trigger should be fired. I have written a trigger on feeditem with after insert event, but my trigger is not getting fired. Can anyone help ?

 

cloudcodercloudcoder

Can you post your code so I can have a look and provide some feedback

Seema ASeema A

Hi ,

 

Hey thnx , problem got solved , i was not giving parentID , that was the mistake.