1

Can we deactivate chatter for a specific object OX and profile PY pair? Or make read-only if that's a thing.

The issue is that profile PY must use chatter normally on other objects and object OX needs chatter activated for other profile types. So this has to be a profile-object combination permission. Can we get that fine-grained in SF or has anyone figured out a workaround?

1

There are at least two workarounds. Both solutions will render the object's feed items read-only. There's no way to completely disable feed items on an object on a per-profile basis.

Page Layouts

Create a new page layout, remove the Chatter actions, assign to the profile.

Trigger

Create a new trigger on FeedItem, and you can block the actions.

trigger BlockItems on FeedItem (before insert) {
  if(0 < [select count() from profile where id = :userinfo.getprofileid() and name = 'restricted']) {
    for(FeedItem item: Trigger.new) {
      if(item.ParentId.getSobjectType() == SomeObject__c.SobjectType) {
        item.addError('You cannot add a post to to this type of record.');
      }
    }
  }
}
  • Thank you for the swift response. I'll try to walk myself through it. Line 1: Add trigger to FeedItem (the Chatter object?) Line 2: Find the user's profile record and check if name is 'restricted' (replace with PY right?). If so, proceed. Line 3: Loop through triggering feed items (can be more than one?) (either the chatter box itself or individual chatter posts? No idea how Chatter organizes objects). Line 4: If feed item parent is of given object type, proceed (here I use OX?). Line 5: Call out error. (error popup and blocks insertion?) – Christos Nov 8 '18 at 23:57
  • @Christos (1) Yes, (2) Yes, change to PY, (3) Theoretically. Also see docs for related methods/objects, (4) Yes, change to OX as appropriate, and (5) Yes, the user will get a popup when they try to post the message. – sfdcfox Nov 9 '18 at 0:03
  • Thank you so much I appreciate the guidance. I haven't started using Apex yet so I had to stare at this for a while. I'll start looking into how to append this code to my org now.. – Christos Nov 9 '18 at 0:06

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.