Let's say we have a custom class Incident, which represents some sort of a customer-impacting incident (like a service outage). Every incident is related to Account through a standard lookup. Incidents have an ETR (estimated time of resolution).

Whenever one or more incidents have their ETR updated, we want to email the customer and notify them of the fact. The email should contain the list of incidents that have been updated and their new ETRs. Incidents are often updated in batches by an external system through the API.

I have no problem with the trigger that figures out which incidents should be included in an email, but I'm struggling with how to send this information to the VisualForce template. I can access the list of all incidents related to an account if I set the account as the related object, but how do I know which ones just changed without the trigger context?

I've thought about adding a new field to incidents to mark them as "ETR changed", and then clear the flag after the email is sent. This way I can render only those incidents in the VF template that have the flag set. I'm not sure if Messaging.sendEmail(email) is synchronous, however, and am worried about race conditions with sending the email and clearing the flag.

Any suggestions?

  • How about a sent email timestamp on Account, an ETF update timestamp on Incident, and a checkbox formula field on Incident that is true if the ETF timestamp is later than the email timestamp? Nov 4, 2017 at 3:08
  • @DavidCheng That would probably work, thanks for the suggestion. I may end up going with that if I can't think of anything else. I think this is a legitimate answer, could you post it as that?
    – Egor
    Nov 6, 2017 at 16:35

1 Answer 1


You could try a sent email timestamp field on Account, an ETF update timestamp field on Incident, and finally a checkbox formula field on Incident that is true if the ETF timestamp is later than the email timestamp.

  • I reviewed this and it would have been a viable solution. We ended up changing the structure of our SF objects, however, which eliminated the problem entirely.
    – Egor
    Nov 7, 2017 at 18:05

You must log in to answer this question.

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