+ Start a Discussion

Clone a look up

Hi Guys,

I have a Lead custom field called Country (look up)

When I convert the lead the field is mapped  to the Account Country (look up)

the question is:

I have created a 2nd Country look up, the purpose is when converting  the lead the "Country"  info will go to the Contact too!!

I need a trigger that updates Country2__c with the same info I have in Country__c


1 object : LEADS

2 fields : .Country__c & Country2__c

Expected result: get autopopulated Country2__c with the same value as Country__c

I have written this:

trigger UpdateCountry2 on Lead ( before update, after insert) {

  List<String> conList = new List<String>();
  for (Lead n:Trigger.new){
  List<Lead> leadList= [SELECT Id, Name, Country__r.Id FROM Lead WHERE Id in :conList];
  Map<ID, Id> nameToId = new Map<Id, Id>();
  for(Lead c : leadList) {
    nameToId.put(c.id, c.Country__r.Id);
  for (Lead n:Trigger.new){
  n.Country2__c = nameToId.get(n.Country__c);



But it does not work!! any ideas!!! Thank you

Best Answer chosen by Admin (Salesforce Developers) 

trigger UpdateCountry2 on Lead ( before update, before insert) {

  for (Lead n:Trigger.new){
    n.Country2__c = n.Country_c;