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
davcondevdavcondev 

Before trigger prevent insert of some records without error?

I need to suppress the creation of some Chatter feed items based on the parent object without causing error or rollback (I'd rather not get into the fairly convoluted why). I'm thinking it should be possible to do this using a before trigger, but I haven't figured out how yet. Any pointers?

trigger suppressSelectedFeedItems on FeedItem (before insert) {
  for (FeedItem fi: trigger.New){
    if(String.valueOf(FeedItem.ParentId).startsWith('XYZ')){
      //I need something here to suppress the insert of this record without reporting an error
      //fi.addErrorNotReally();
  }
}
Ramu_SFDCRamu_SFDC
Hi Davcondev, before insert can do some logic in the background before inserting a record (the record will however gets inserted with or without this logic) unelss there are any validation rule errors that are preventing the record from getting created. Hope this helps