function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Freddie GarciaFreddie Garcia 

Mapping 1 custom lead field to 2 other objects (Opportunity and Contact Objects)

I need to map a custom text area field from the lead object to the opportunity (currently mapped) as well as the contact object.  All the same field type and name.

 
Best Answer chosen by Freddie Garcia
sc2510sc2510
This is how I do it:
  1. create another hidden field on the lead object, I'll call it lead_2
  2. create a workflow rule that triggers when
    • the first lead field (lead_1) is not blank AND lead_1 is not equal to lead_2
  3. create a field update on lead_2, use the formula editor and set it equal to lead_1
  4. activate the rule
  5. you can then map one of these fields to the opportunity and the other to the contact

All Answers

Keena FloodKeena Flood
Hey Freddie,

Please see instructions below.

1) Login to Salesforce with appropriate administrative privileges.
2) Navigate to  Setup > Customize > Leads > Fields.
3) Scroll down to your custom fields and click Map Lead Fields.
4) For the custom text area field, choose the corresponding contact fields (denoted by “Contact:” before the field name) from the drop down.
5) When finished, click Save.

Hope this helps!

KF
☯ BonY ☯☯ BonY ☯
Hi Freddie,

Please try the below trigger and let me know if you face any issues
 
trigger checkConvert on Lead (After update)
{
  if(Trigger.isUpdate)
  {
     Map <id, string> l1 = new Map<id, string>();
     Map <id, string> l2 = new Map<id, string>();
     Map <id, string> l3 = new Map<id, string>();

     for(Lead ld1 : Trigger.new)
     {
        l1.put(ld1.convertedaccountid, ld1.test__C);
     }  
     
     for(Lead ld2 : Trigger.new)
     {
        l2.put(ld2.convertedcontactid, ld2.test__C);
     } 
     
     for(Lead ld3 : Trigger.new)
     {
        l3.put(ld3.convertedopportunityid, ld3.test__C);
     } 
       
     List<Account> ac = new List<Account>();
     for(Account a1 :[select id, Account_Lead__c from account where id in :l1.keyset()])
     {
       a1.Account_Lead__c = l1.get(a1.id);
       ac.add(a1);
     }
     update ac;
    
     List<Contact> ac1 = new List<Contact>();
     for(Contact a2 :[select id, Contact_Lead__c from contact where id in :l2.keyset()])
     {
       a2.Contact_Lead__c = l2.get(a2.id);
       ac1.add(a2);
     }
     update ac1;
     
     List<opportunity> ac2 = new List<opportunity>();
     for(opportunity a3 :[select id, Opportunity_Lead__c from opportunity where id in :l3.keyset()])
     {
       a3.Opportunity_Lead__c = l3.get(a3.id);
       ac2.add(a3);
     }
     update ac2;
     
   }
}

Test__c is Lead Custom Field.

Mapping to

Account_Lead__c in Account Object,
Contact_Lead__c in Contact Object,
Opportunity_Lead__c in Opportunity Object.


Thanks,
♔BoNi
sc2510sc2510
This is how I do it:
  1. create another hidden field on the lead object, I'll call it lead_2
  2. create a workflow rule that triggers when
    • the first lead field (lead_1) is not blank AND lead_1 is not equal to lead_2
  3. create a field update on lead_2, use the formula editor and set it equal to lead_1
  4. activate the rule
  5. you can then map one of these fields to the opportunity and the other to the contact
This was selected as the best answer
Freddie GarciaFreddie Garcia
sc2510 that is what I did thanks!