This post is a part of the daily blog series
A Tip A Day, daily dosage of learning!
Day #1 – Lead Conversion Mapping To Standard Fields
Today, I was working on lead fields mapping for lead conversion – standard feature, simple right? The standard feature that lets you map Lead fields to Account, Contact and Opportunity objects. (Can be accessed from Setup–> Lead–> Fields –>Map Lead Fields) So, when a lead converts, the field values are copied from Lead to the chosen object’s fields based on the mapping.
Learning: What I’ve learnt is that I “Cannot map lead fields to standard Account fields” – that’s a bummer! So, I couldn’t map Lead’s Account Type field to Account’s Type standard field.
Solution – The workaround I tried was to create a custom field in Account – named Customer Type and map that field to the Lead Type field in the Lead mapping.
Great, but that doesn’t complete the job as the existing accounts do not have any value in this new field. So, I just wrote this simple code to copy all of the ‘Type’ field values to ‘Customer Type’ in all accounts and also replaced the Type field in the Account page layouts with Customer Type. So, going forward we will just use Customer Type instead of the Type field. You should run this code one time in Developer Console –> Debug –> Execute Anonymous Window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Account> accList = [SELECT id,type,customer_type__c FROM account WHERE type!=null LIMIT 200]; | |
for(account a:accList){ | |
a.customer_type__c = a.type; | |
} | |
update accList; |
Read all other tips of the blog series here – A Tip A Day, daily dosage of learning!
One Reply to “A Tip A Day #1 – Lead Mapping to Standard Fields”