Reply
Contributor
Iand
Posts: 7

Creating a Custom Case Field "To" Email Address

I am attempting to create a custom case field to show to "To" email as we have several addresses which open support cases. I would ideally use this address to let our support know what account/program the support case is being opened under.
 
Alternatively, if there is a way to tag my Custom Program Field (picklist) to populate based of this address (with or without creating it) that would be great too.
 
Any thoughts or suggestions? I am not too tech savvy and ended up our SF administrator!
Regular Contributor
JPSeabury
Posts: 121

Re: Creating a Custom Case Field "To" Email Address

I'm not sure I follow what you're trying to do.  Included among the standard fields of the Case object are "Account Name" and "Contact Name".  Wouldn't these fields suffice to identify which accounts a support case is being opened under?

If you use these fields, then you can also set it up so that when a User is looking at a Account or Contact detail record, they will see all the related Cases that have been opened for that entity.

JP Seabury
Force Monkey
Contributor
Iand
Posts: 7

Re: Creating a Custom Case Field "To" Email Address

Using the Account name should work (haven't needed to use in the past), but how can I get the Account Name to populate based on the email address the inquiry was sent to?
 
Really appreciate the help.
Regular Contributor
JPSeabury
Posts: 121

Re: Creating a Custom Case Field "To" Email Address

In our case, we take cases from three sources:  web site (self-service portal, soon customer web portal, I'm hoping), email and telephone.
 
If the Case is created by a customer logged into the Self-Service portal, the contact / account fields are populated automatically, courtesy of Salesforce.com
 
If the Case originates by eMail (i.e., customer sent email to support@mycompany.com), we redirect the email to some Apex code that we wrote in-house, which automatically creates a new case.  The Apex code looks at the email address of the incoming email and matches up to an existing Contact in our database -- then autopopulates the Contact and Account fields in the Case record.
 
If the Case originates by phone, the Support Rep who takes the call creates a new case, and gets the callers name -- then enters it in the Contact field of the Case record.  SFDC automatically updates the Account field based on the name entered in the Contact field.
 
How does that differ from what you're doing?
JP Seabury
Force Monkey
Contributor
Iand
Posts: 7

Re: Creating a Custom Case Field "To" Email Address

It is precisely the same, we have a web support form that pre-populates most case information (though not account because until this time we had only had one).

 

For phone, our reps choose this info.

 

For email, we have multiple emails boxes from which emails are pulled into salesforce as cases. Currently the Account is automatically populated with what had been our default in the past. I am looking for a way to have the account populate based on the email box that the case is pulled from.

Contributor
Iand
Posts: 7

Re: Creating a Custom Case Field "To" Email Address

I should also mention that not all of our contacts have been pre-populated in our tool, so we cant necessarily populate the account based on the email address of the participant/customer. We need to use the email address of the box the email was sent to.
Regular Contributor
JPSeabury
Posts: 121

Re: Creating a Custom Case Field "To" Email Address

So it sounds like we might be doing things slightly differently ... we use the email address of the person who sent the email to populate the contact field:
 
Code:
// new Case object to be created
Case[] newCase = new Case[0];

// Try to lookup any contacts based on the email from address
// If there is more than 1 contact with the same email address
// an exception will be thrown and the catch statement will be called
try {
   for (Contact vCon_tmp : [Select Id, Name, Email From Contact Where Email = :email.fromAddress Limit 1]) {
      foundContact = TRUE;
      vCon = vCon_tmp;
   }
}
:
:
:
if (foundContact) {
   newCase.add(new Case(Description = myPlainText,
      Status = 'New',
      Priority = '4-Normal',
      Origin = 'Email',
      Subject = email.subject,
      OwnerId = tseQueue.Id,
      ContactId = vCon.Id));
} else {
   newCase.add(new Case(Description = myPlainText,
      Status = 'New',
      Priority = '4-Normal',
      Origin = 'Email',
      OwnerId = tseQueue.Id,
      Subject = email.subject));
}

 
It sounds like you're populating the Account field based on the email address that the Contact sent the email to (rather than our method, using the from email address).  So for instance, if your customer sent the email to McCain@mycompany.com, the Case should be assigned to the "McCain" account.  If they sent the email to Obama@mycompany.com, the Case would be assigned to the Obama account.  If you added another account, you'd have to give them a new email alias to use (i.e., Barr@mycompany.com)?
 
That's a different approach to opening cases, but it's really not much of a logic change in the application I described above.  If taksed with this, I'd create a custom field on the Account object (email2case_alias__c), and then fill it with the appropriate mail alias that you've told your customers to use (i.e., McCain@mycompany.com, Obama@mycompany.com, Barr@mycompany.com).  Then your Apex logic looks something like:
 
Code:
// Try to lookup any contacts based on the email from address
// If there is more than 1 contact with the same email address
// an exception will be thrown and the catch statement will be called
try {
   for (Account vAcnt_tmp : [Select Id, Name From Account Where email2case_alias__c = :email.toAddress Limit 1]) {
      foundAccount = TRUE;
      vAcnt = vAcnt_tmp;
   }
}

 
How's that for being clear as mud? 
 
I guess the key is understanding more about the application you're using to create cases that originate from email.  Whatever application that you're using that is creating those cases can be modified to fill the Account or Contact field, but whatever logic you choose.
JP Seabury
Force Monkey
Contributor
Iand
Posts: 7

Re: Creating a Custom Case Field "To" Email Address

You've described exactly what we are trying to do, but unfortunately I cant provide much more information from our end.
 
I know we have a config and email to case txt files that run our workhorse server, which is what pulls the emails into salesforce as cases.
 
The code for the config file looks something like this (using your examples):
 
Code:
Code:
sfdcconfig.txt

 

<configFile>
 <sfdcLogin>
  <url>http://www.salesforce.com/services/Soap/u/6.0</url>
  <userName>username@mycompany.com</userName>
  <password>xxxxxx</password>
  <loginRefresh>30</loginRefresh>
  <timeout>4</timeout>
 </sfdcLogin>
 <notify>
        <notifyEmail>McCain@mycompany.com</notifyEmail>
        <from>McCain@mycompany.com</from>
        <host>host.server.com</host>
        <!--port>25</port-->
        <user>McCain</user>
        <password>xxxxx</password>
        <service>com.sforce.mail.SMTPNotification</service>
    </notify>
 <services>
  <com.sforce.mail.EmailService>C:\\McCainEmailAgent60\\email2case.txt</com.sforce.mail.EmailService>
 </services>
</configFile>

 
The above doesn't really mean much to me, this was set up by a third party a few years ago and we have been winging it since. I was able to copy the rule above (and the email to case file) and make the necessary changes to add new email addresses whose emails are pulled into salesforce.
 
We may not even need the account to be automatically populated, even exposing a custom field to capture this "To" email address would provide the reps with the info they need to choose the correct program/account.
 
Regular Contributor
JPSeabury
Posts: 121

Re: Creating a Custom Case Field "To" Email Address

[ Edited ]
Yep, you're "outside the box" now -- this isn't a SFDC issue.  This is something you need to change in the third-party integration application.  Best option is to go back to that 3rd party who set this up and get a quote for implementing your change requirements. 
 
If they're no longer around, or that's not an option, you probably need to contract a code monkey (SOAP / XML expertise) to fix this for you.


Message Edited by JPSeabury on 09-09-2008 05:01 PM
JP Seabury
Force Monkey
Contributor
Iand
Posts: 7

Re: Creating a Custom Case Field "To" Email Address

I guess that is the road we will have to go down.
 
Thanks again for the insight and the responses.
 
ID