I have written apex trigger codes on both Case and EmailMessage objects, which are both fired by before insert events. They run pattern and matcher classes to block several possible formats of a credit card number.

The problem is that, when a case is created by standard Email2Case functionality of Salesforce, I am able to view the unblocked credit card number in feed post generated by the email itself. See screenshots below:


Credit card number is blocked in above picture and replaced by "K.KART_NO". However, when I expand this feed post, I am able to view the unblocked number.


This credit card number is blocked in everywhere else - case subject, case description, emailmessage subject and emailmessage body.

Does anyone have a logical / technical explanation for this occurrence, and maybe a solution for it?

Thanks in advance.


After adding the FeedItem trigger suggested by crmprogdev the problem is not resolved. Problem still persists in the same way. See the new feed post below (when it is collapsed, blocked version displays as shown in above picture):


I used workbench tool to query the faulty FeedItem and check all its details. See the screenshot below:


I was expecting the body to host the text with unblocked number, but it is empty. No field includes this value, which is a bit odd for me. What could it possibly reference to?


I queried the EmailMessage object, and saw that I have skipped the HtmlBody field. I updated my EmailMessage trigger to also check and block HtmlBody, and, it worked!

enter image description here

1 Answer 1


As you say you already have a trigger that fires on before insert on the EmailMessage object, this seems a bit surprising. The CaseFeed appears to come directly from the EmailMessage event where the Type picklist value would show as:

EmailMessageEvent — generated event when an email related to a case object is sent or received.

You can't add a trigger to CaseFeed but you can put a trigger on FeedItem to allow you to sort based on the ParentId being a reference to CASE and Type = EmailMessageEvent. That would seem to me to be the only additional way of solving your issue if your trigger on EmailMessage isn't preventing this from occurring to begin with.

  • Thanks a lot for your insight. It looks like this is the only way to go. I'm going to begin preparing this trigger and will share the outcome with you. Also thanks to @cropredy for editing the title, I accept that mine was not worded properly.
    – TSunar
    Jun 11, 2016 at 17:03
  • Update; I added a new trigger on FeedItem, but unfortunately this issue still remains. I am updating my question to include some more details.
    – TSunar
    Jun 11, 2016 at 18:20
  • I see where you updated your email message trigger to update the html body. Glad to see you got it sorted. Good job of diagnosing the root cause of your issue.
    – crmprogdev
    Jun 11, 2016 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .