Does the data in "Individual Email Results" get lost when converting a Lead to a Contact? - Answers - Salesforce Trailblazer Community
Ask Search:
Kim VlasnikKim Vlasnik 

Does the data in "Individual Email Results" get lost when converting a Lead to a Contact?

One of my users converted a Lead to a Contact, and says that the Individual Email Results from the Lead record were not transferred to the Contact record. There was no existing Contact record to merge with; she created a new Contact record when she converted them. Any ideas? We are using Enterprise edition.
Paul FischerPaul Fischer
Did the user change the email address of the Lead/Contact? 

Has the individual email results related list been added on the Contact page layout?

Check out the exacttarget config guide here and search for individual email results: http://help.exacttarget.com/en-US/documentation/integrated_products__crm_and_web_analytic_solutions/exacttarget_salesforce_integration_v2_non_enterprise_2_0/exacttarget_for_appexchange_configuration_guide_for_salesforce_enterprise_and_unlimited_editions/

Also, you want to make sure you have any exacttarget fields mapped to contacts on conversion. Go to Setup --> Customize --> Leads --> Fields then click the Map Leads Fields button.
Kim VlasnikKim Vlasnik
Thanks for addressing my question, Paul! They did not change the email address, and our Contacts layout does have Individual Email Results visible for this user.

I can't find anything related to converting Leads in the document you linked to, but thanks for pointing me there.

Individual Email Results aren't a mappable field - they're an Activity, are they not?
Paul FischerPaul Fischer
Hi Kim, yes Individual Email Results are an Activity. The only think I can think happened is that they got mass deleted. I would log a case with xacttarget to see if they can shed more light on this--keep me posted. 
Kim VlasnikKim Vlasnik
I've opened a case with Customer Support and will let you know what I find out. Thanks!
Katie DellKatie Dell
Did you ever find a resultion to this?  We are encountering the same issue.
Kim VlasnikKim Vlasnik
Unfortunately, no - and when I spoke with Customer Support, they said because it was a custom object (I inherited an org and this was in place before I got here), they could not offer support. They advised that I contact ExactTarget/Marketing Cloud for support, and I logged a case there, but never heard from them. It was very frustrating. I hope you have a better troubleshooting experience than I did!
Katie DellKatie Dell
I will let you know.  No luck so far though.  Plenty of information on how Marketing Cloud tracks individual email results on the lead or contact but nothing about what happens when you convert that lead.
Katie DellKatie Dell
So it turns out there is an Apex trigger that you can implement to move the lead individual emails to the contact.  We got the instructions and code from Marketing Cloud support.  Not sure if you can retroactively move emails or if it is triggered at the time of conversion but I'm hopeful we can at least avoid this issue going forward!
Tom GriffinTom Griffin
Hey Katie, Would you be willing to share that code? It would be greatly appreciated.
 
Katie DellKatie Dell
Below is the code we got from MC/ET support.  We hit a few speed bumps since this was our first Apex trigger deployment but our developer got it working last week!

-Katie

Create New Apex Trigger
trigger individualEmailResultsConversion on Lead (after update) {
Map<ID, Lead> convertedLeads = new Map<ID, Lead>();
for(Lead lead:trigger.new) {
if( lead.isConverted ) {
convertedLeads.put(lead.id, lead);
}
}
if( convertedLeads.size() > 0 )
{
xtma_Individual_Email_Result__c[] emailResults = [select id,
Contact__c, Lead__r.ConvertedContactId from xtma_Individual_Email_Result__c
where Lead__c in :convertedLeads.keySet() and Contact__c = ''];
if( emailResults.size() > 0 ) {
for(xtma_Individual_Email_Result__c ier : emailResults) {
ier.Contact__c = ier.Lead__r.ConvertedContactId;
}
update emailResults;
}
}
}

For Production deployment they listed the trigger configuration as below
User-added image

Test class
"@IsTest" worked alone on config but  "@isTest (seeAllData=true)" was required on production
This is used to open up data access to records in the org. more details on when to use what: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_seealldata_using.htm
 
public class individualEmailResultsConversionTests {
public static testmethod void individualEmailResultsConversionTest1() {
Lead[] newLeads = new Lead[0];
try {
Lead lead = new
Lead(LastName='Smith',FirstName='John',Email='test@testcom.com',Company='Unite
xtronics');
insert lead;
xtma_Individual_Email_Result__c ier = new
xtma_Individual_Email_Result__c(Lead__c=lead.Id);
insert ier;
System.debug('initial ier id: ' + ier.Id);
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(lead.Id);
LeadStatus convertStatus = [select Id, MasterLabel from
LeadStatus where IsConverted=true limit 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvert[] leadConversions = new
Database.LeadConvert[] { lc };
Database.LeadConvertResult[] results =
Database.convertLead(leadConversions);
System.assert(results[0].IsSuccess());
}catch(QueryException qe) {
System.debug(qe);
}
}
}

 
Craig ZehrCraig Zehr
I have added a PB to update the Contat field on the IER, and it is working, but an hour later I look at the IER record and the contact field has been cleared. My guess it is from the MC Connector, but I can't tell for sure. How can I prevent this from happening?
Paul FischerPaul Fischer
I've posted an idea here to make this native functionality of the Marketing Cloud Connector. Please vote for it here: https://success.salesforce.com/ideaView?id=0873A0000003dg6QAA