• qbrown
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi, i rewrote this post because I realized I wasnt being clear enough. Heres what im trying to do: when a lead is converted the parent account in lead needs to go over to the parent account in accounts. I found quickly that standard and custom fields cant be mapped together, but that a trigger could pull the data on conversion. I found a trigger here that I've attempted to use and I dont get any syntax errors with it, but when a lead is converted the parent account in accounts is left blank. Any help or suggestions would be appreciated, thanks!

heres the trigger:

 

trigger populateParentAccount on Account (before Insert){
  List<Lead> convertedLeads=[SELECT Id, ConvertedAccountID, Parent_Account__c
  FROM Lead WHERE IsConverted=True AND ConvertedAccountId IN :trigger.new];
  Map<ID,ID> acctParentMap=new Map<ID,ID>();
  for (lead l: convertedleads){
    acctParentMap.put(l.ConvertedAccountId,l.Parent_Account__c);
  }
  for (account a:trigger.new){
   if (acctParentMap.containsKey(a.Id)){
      a.ParentID=acctParentMap.get(a.Id);
      
   }
  }
}

 

  • January 16, 2013
  • Like
  • 0

Hi, i rewrote this post because I realized I wasnt being clear enough. Heres what im trying to do: when a lead is converted the parent account in lead needs to go over to the parent account in accounts. I found quickly that standard and custom fields cant be mapped together, but that a trigger could pull the data on conversion. I found a trigger here that I've attempted to use and I dont get any syntax errors with it, but when a lead is converted the parent account in accounts is left blank. Any help or suggestions would be appreciated, thanks!

heres the trigger:

 

trigger populateParentAccount on Account (before Insert){
  List<Lead> convertedLeads=[SELECT Id, ConvertedAccountID, Parent_Account__c
  FROM Lead WHERE IsConverted=True AND ConvertedAccountId IN :trigger.new];
  Map<ID,ID> acctParentMap=new Map<ID,ID>();
  for (lead l: convertedleads){
    acctParentMap.put(l.ConvertedAccountId,l.Parent_Account__c);
  }
  for (account a:trigger.new){
   if (acctParentMap.containsKey(a.Id)){
      a.ParentID=acctParentMap.get(a.Id);
      
   }
  }
}

 

  • January 16, 2013
  • Like
  • 0