1

I just noticed that in global search results, data mentioned in email body or email subject is not accessible for search results (SOSL) due to salesforce search limitations.

Ref: https://help.salesforce.com/HTViewHelpDoc?id=search_fields_case.htm&language=en_US

There are some cases where users add email addresses/name in subject where somebody else is sending email behalf of the actual user, and there's no possible way to find that case/lead in global search using actual user's name.

Ex.

Doctor's secretary communicates with call center using her email address behalf of doctor which is email-to-case for salesforce, Call center remembers name of doctor not secretary, now if call center manager wants to find case for that doctor using doctor's name, there's no possible way to find case as doctor's name is not mentioned in case name. (email to case will add email address and name from sender)

Now there's one way to make search possible as salesforce is not providing extended search for this:

  • Create custom Test(Long) fields for email subject and email body
  • Copy email subject and body data into that custom field

Now, salesforce global search will be able to search through the custom field, case will appear in search result.

Question is:

  • Is there any other way to achieve this functionality?
  • If not, do we have any other option than trigger to put email body and subject data in custom field?

As per character limit in custom field, I would not recommend adding email description/body data in custom field, instead I have changed my logic to fetch to/cc/bcc email addresses in custom field which would be available in global search results, and would recommend call center users to add doctor's email in Cc or Bcc.

Class:

trigger EmailCopy on Case (before update, before insert) {


        copyEmail.emailCopier(Trigger.new);

}

Trigger:

public with sharing class copyEmail {

    public static void emailCopier (list<Case> caseList){

        for(Case each : caseList)
        {
            list<EmailMessage> add1 = [select ToAddress from EmailMessage where ParentId =:each.id];
            list<EmailMessage> add2 = [select CcAddress from EmailMessage where ParentId =:each.id];
            list<EmailMessage> add3 = [select BccAddress from EmailMessage where ParentId =:each.id];

            for(EmailMessage x : add1)
            {
                each.Email_Data__c = x.ToAddress + ' ';
            }
            for(EmailMessage y : add2)
            {
                each.Email_Data__c = each.Email_Data__c + y.CcAddress + ' ';
            }
            for(EmailMessage z : add3)
            {
                each.Email_Data__c = each.Email_Data__c + z.BccAddress + ' ';   
            }

        }

    }

}

Update

Global search will be able to search only if the case has been edited after sending email, as service console view (chatter based email) doesn't make any edit/change on case when email is being sent so trigger won't go off unless we're manually editing the case.

How to set trigger off even when we're sending email using console email not from case but from rich email functionality (feed based view) ?

Still open for other suggestion/solution.

  • In the example you cite, wouldn't the case get reassigned to the Account of the Dr with the secretary as the primary contact or something similar? This would seem to be a matter of how you configure the logic for assigning cases to the proper account. I recognize that each org has different use cases for cases and this may not fit your model, thus the reason for the commentary. – crmprogdev Sep 2 '15 at 13:49
  • That was just simple example where we don't use secretary name or something, This was just to display logic behind the question. We have case assigned to one contact which is not related to other contact but if you search by name of that other contact, that case should appear in global search. That's the requirement. Logic with case assignment should be based on email but this is the issue when multiple parties are involved in same case and communication hat moves to one person from another. – Dave Sep 3 '15 at 12:33
  • My only point was that perhaps your process is flawed where you're not properly relating the case to the Account and adding a related contact so the connection can be made. That might be an alternate approach to solving the problem. Again, I don't know how you've implemented cases or your use of them to advise. Just injecting a thought. Will see what others have to say. Good luck. – crmprogdev Sep 3 '15 at 12:58
  • Haven't got any response so far, I guess I'll have to find solution using trigger now. – Dave Sep 15 '15 at 14:00

Your Answer

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

Browse other questions tagged or ask your own question.