0

I'm facing a problem when I try to implement a functionality that lets users see if there is a unread Email on a Case, indicated by an icon in a formula field. I have a workflow rule that adds the icon when an email is received on a Case, by setting a checkbox the following rule criteria was fullfilled on the EmailMessage object:

 (Email Message: Is Incoming equals True) and (Email Message: Status equals New) 

In the formula field checking the checkbox value and set the appropirate icon, this works fine. The checkbox is set and the icon is added. But when I try to remove the icon when the Email's status changes from New to Read I could not get my other workflow rule to fire, also on the EmailMessage object with the following rule criteria:

 (Email Message: Is Incoming equals True) and (Email Message: Status not equals New) 

I could not see anything indicating that i had fired in my debug logs. So I started writing a Trigger that were supposed to set the checkbox to False (onBeforeInsert and onBeforeUpdate):

Set<ID> caseIds = new Set<ID>();
    for(EmailMessage message : newList){
        if(message.Incoming == true && message.Status == 'Read'){
            caseIds.add(message.parentId);
        }
    }
    List<Case> csUpdateList = [select id, New_Email__c from Case where id IN :caseIds];
    for(Case c : csUpdateList)
        c.New_Email__c = false;

    update csUpdateList;

This still doesn't solve the problem and nothing is shown in my debug logs, I'am obviously missing something but I cannot figure out what. What is the best way to recognice that an Email has been read (opened)? I assume it is checking the Status, and if so, what is the best way to "catch" this event? If I could solve this with workflows I would prefer it, but any help with the Trigger is highly appreciated.

Ciao!

  • how about a report - cases with email message, where email status = new? – gorav Jan 16 '17 at 19:38
3

An alternative to consider is to use a VF page as an element within your standard Case page layout.

  • The VF page is associated to a controller with access to the Case id
  • The controller can query the children of the Case (that is, EmailMessage)
  • The controller can thus display on the VF page a message indicating an unread EmailMessage (and links too)

Downsides?

If you need to use SFDC reports to report on Cases w/ unread emails (or List Views) - these won't work

  • Thanks for your answer, this is kind of what I started implementing as an idea yesterday, I'm gonna make the icon clickable with an url to a VF page that will just redirect me to the email page. And the logic for everything else will be in a controller. – erikduvet Jan 8 '15 at 7:54
1

This is not possible, that action doesn't generate a DML execution. As far as I know there are no workarounds available.

https://success.salesforce.com/ideaView?id=08730000000biKgAAI

  • Thanks for your answer, been seraching for anything about this but I must have missed that link. Do you know if the same thing applies for Comments on a Case? Meaning, is it possible to implement the idea I'm searching for in question for Case Comments? An icon showing a new comment and when the User clicks in to the case it dissapears? – erikduvet Jan 7 '15 at 15:34
  • 1
    @You can do it for case comments. I have done it a few times before. – PepeFloyd Jan 7 '15 at 16:41
  • It's interesting that the Appexchange app Email to Case Premium has this feature included, including a workflow rule to alert the user if there is a new message. They seem to copy all the emails into Comments to achieve this. It's a good package. Have a look at it, it might help. – JodieM May 26 '15 at 7:23
1

Here's the workaround Implementation explained on YouTube: https://youtu.be/AL13GE4vYe0

In summary:

Add a Custom checkbox field 'New Email?' on case to let users know whether a new Email Arrives in the case.

Add an inline blank VF page on Case page layout, that invokes a controller to update the New Email flag whenever a Email's status is either New or Read.

Hope this helps!

  • Can you at least try to summarize? – Adrian Larson Jan 16 '17 at 19:25
  • @AdrianLarson - Having Custom checkbox field 'New Email?' on case, to let users know whether a new Email Arrives in the case. - Inline blank VF page on Case layout , invoking a controller to update the New Email flag whenever a Email's status is either New or Read. – Naval Jan 16 '17 at 20:59
  • 1
    Please edit your post with any additional content. – Adrian Larson Jan 16 '17 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.