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
RajivRajiv 

Trigger for Chatter

Hi,

 

I wrote trigger for Chatter . This trigger basically send  an email to a person whatever we right on their wall, but the main problem is that whenever I write on my own wall this trigger doesn't execute/ work , It should work and send email to me also. Right now I am comparing  userId of userobject  with ParentId of UserFeed. 

 

Can anyone help on this issue. How can I solve this problem.

 

Thanks,

Rajiv

ildiavolorossoildiavolorosso

There are two types of Chatter triggers: FeedItem and FeedComment. Are you firing a trigger on both or just one?

 

BTW - From a design perspective, I'm curious why you're writing a trigger to send an email. When you post on someone's profile, it already sends them an email. In other places, you can now use @mentions and that will send an email. Is there a functionality gap you're trying to overcome here?

RajivRajiv

Hi,

 

 

I have wriitten trigger for both Feeditem and Feedcomment object.  Feedcomment trigger works fine but  Feeditem trigger won't execute when I post on my own wall.

 

SOQL query for  userfeed which I use:

List<UserFeed> userFed = [SELECT Id, Type, body ,ContentFileName, InsertedById,ParentId, FeedPost.Body, FeedPost.Title, FeedPost.ContentData, FeedPost.FeedItemId from UserFeed where parentId =: Ids  ];

 

Where Ids is the parentId of FeedItem.

 

Right now Iam using UserFeed. Should I have to use different  Feed. I also checked with newsfeed and userprofilefeed but it  was not worked. Can you Please Suggest me which Feed I have to use so that sending mail from my wall is possible.

 

Thanks,

Rajiv

 

 

ildiavolorossoildiavolorosso

Some more color is available here:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_ignoring_operations.htm?SearchType=Stem&Highlight=FeedItem|FeedItems

 

I don't see any way around that, when posting your own status updates, but someone else may have an idea.

 

I'm still curious: Chatter already sends an email when someone posts to your profile. Are you looking to send email to someone other than the user whose profile is being posted to?

MirandaRaglandMirandaRagland

FeedItem insert triggers don't run for changes to the user status. You'll have to add a user object update trigger and detect a change to the CurrentStatus field.