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
SwayampravaSwayamprava 

Delete chatter post automatically with keyword 'Created' or 'updated'.

Hi,

  Can any body help me on this. I want to delete the chatterposts automatically with keyword 'Created' or 'Updated'.  This should be a trigger  on chatter feed or anything else? 

 

I have tried on Chatter teed Trigger::: But this is not working . When i created any new record the Chatter post "The Owner has created the Record." chatter post is still there.

 

My code---

 

Trigger delete_Records_with_Created on FeedItem (after insert) {

Feeditem thisf;

for(FeedItem f:Trigger.new){

   thisf=f;

}

String body_text=thisf.body;

if(body_text.contains('created')==true)

delete thisf;

}

 

DeepeshDeepesh

A suggestion. Would it be ok if you don't allow the feeditems to be created? I mean instead of after insert trigger deleting those records, just skip such records in a before insert trigger.

SwayampravaSwayamprava

Yes it is ok for me. If you have the solution Please forward to me.

SwayampravaSwayamprava

If it is before insert trigger then how to prevent the record to be inserted.

DeepeshDeepesh

Just addError to records which you don't want to be inserted. Check this:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_exceptions.htm

SwayampravaSwayamprava

If i will add an Error to the record then this wil dispaly me the error message. My requirement is not to insert those records. Not to display any Error message and control from there.