Sub topic 8
Lead field mapping during conversion
This chapter covers how Salesforce copies data from a lead to the account, contact, and opportunity it creates. It assumes you can navigate Setup and Object Manager and know the standard Account, Contact, and Opportunity objects. The Apex and SOQL examples need basic syntax knowledge. You should also have seen what conversion creates, from the previous chapter.
What field mapping does
When a lead converts, Salesforce creates new records and fills their fields from the lead. A mapping is a rule that says "this lead field feeds that field on the target object." Salesforce applies the mappings at the moment of conversion and does not apply them again later.
Two kinds of mapping exist:
- Standard mappings. Salesforce defines these and you cannot change them. Examples are the lead name going to the contact name, the company going to the account name, and the lead email going to the contact email.
- Custom mappings. You define these for custom lead fields. A custom lead field can feed one field on the account, one on the contact, and one on the opportunity.
Standard lead fields cannot be remapped. If you want standard data in a different place, such as an extra field on the opportunity, you need a custom lead field, a formula, or automation. This is a common surprise for admins who expect to redirect the standard Industry field.
Where to configure mappings
Open Setup, then Object Manager, then Lead, then Fields & Relationships, and click Map Lead Fields. The page lists every lead field, standard and custom. Next to each custom field are three dropdowns, one each for Account, Contact, and Opportunity.
To change mappings you need the Customize Application permission. A user who can convert leads does not automatically have it.
The page lists only target fields that Salesforce considers compatible. If a field you expect is missing from a dropdown, one of the rules in the next section is probably why.
Rules for compatible fields
Salesforce restricts which fields can be paired. The details vary by field type, but these rules cover most cases:
| Rule | Why it matters |
|---|---|
| Data types must be compatible, for example text to text, number to number, date to date | The dropdown hides incompatible targets, so a lead picklist may not offer a number field |
| A picklist can feed a text field | Useful when the target does not need the controlled values |
| Target fields must be real, writable fields | Formula, roll-up summary, and auto-number fields cannot receive mapped data |
| The target should be at least as long as the source | A shorter target can cause truncation or an error at conversion |
| Each target field takes data from one lead field | You cannot merge two lead fields into one account field through mapping |
Check field lengths before you map. A lead field of 255 characters mapped to a target of 80 characters works until a user enters a long value, and then conversion may fail for that record.
For picklists, compare the value lists on both sides. Mapping a picklist to a picklist copies the selected value as text. If the target is a restricted picklist and the value is not in its list, the conversion can fail. When the lists differ, map the lead field to a text field or align the values first.
Mapping a custom field step by step
Suppose your company collects a referral code on leads and wants it on the contact. Create the custom fields first, since a mapping can only point at fields that already exist.
- Create
Referral_Code__cas a text field (length 40) on Lead. - Create
Referral_Code__cas a text field (length 40) on Contact. Keep the length equal to or larger than the lead field. - Go to Lead, Fields & Relationships, Map Lead Fields.
- In the row for
Referral Code, chooseReferral Codein the Contact dropdown. Leave Account and Opportunity as--None--. - Click Save.
Using the same API name on both objects is not required. It makes queries, reports, and debugging easier to read, so many teams do it by convention.
Now verify the mapping with a script. This example assumes the two fields above exist and the mapping is saved. Run it in Anonymous Apex.
Lead l = new Lead(
FirstName = 'Grace',
LastName = 'Hopper',
Company = 'Compiler Works',
Email = '[email protected]',
Referral_Code__c = 'REF-2026-001'
);
insert l;
LeadStatus convertStatus = [
SELECT MasterLabel
FROM LeadStatus
WHERE IsConverted = true
LIMIT 1
];
Database.LeadConvert lc = new Database.LeadConvert();
lc.setLeadId(l.Id);
lc.setConvertedStatus(convertStatus.MasterLabel);
lc.setDoNotCreateOpportunity(true);
Database.LeadConvertResult result = Database.convertLead(lc);
System.debug('Success: ' + result.isSuccess());
Contact c = [
SELECT Id, Name, Email, Referral_Code__c
FROM Contact
WHERE Id = :result.getContactId()
];
System.debug('Contact referral code: ' + c.Referral_Code__c);If the mapping works, the debug log shows REF-2026-001. If it shows null, the mapping is missing or saved against the wrong object. Check the Map Lead Fields page before looking anywhere else.
What happens to unmapped fields
An unmapped custom lead field is not lost. Its value stays on the converted lead record, which Salesforce keeps in a read-only state. You can still see the lead in reports, and you can query it with SOQL:
SELECT Id, Name, Referral_Code__c, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId
FROM Lead
WHERE IsConverted = true
ORDER BY ConvertedDate DESC
LIMIT 10However, the data is not visible on the account, contact, or opportunity. Users working in those records will not see it unless you mapped the field or built a related display.
Mapping is also a one-time copy, so editing the lead after conversion is not possible. A change to the mapping applies only to future conversions. Existing contacts do not update when you add a mapping later. To backfill, use a data load or a script that reads ConvertedContactId from converted leads and writes the value to each contact.
Mapping and the three target records
Each target object has its own behavior to keep in mind.
Account
The account receives the company name, and typically address and industry data, depending on the standard mappings. Custom account fields are good for company-level data such as number of employees by region or a partner tier. Because several leads can convert into the same account over time, an account field mapped from a lead holds the value from whichever conversion created the account. Later conversions into that existing account follow the matching rules covered in the next chapter, not a fresh mapping pass over existing data.
Contact
The contact is the main destination for person-level data: name, email, phone, and mailing address. Most custom mappings go here, since details about the individual belong to the individual.
Opportunity
Opportunities are created only if the user, or your code, does not opt out. The opportunity name comes from the conversion screen, where the user can edit it. Custom opportunity fields are useful for sales context captured at the lead stage, such as budget range or estimated deal size. If you skip opportunity creation with setDoNotCreateOpportunity(true), opportunity mappings are not applied, because no record exists.
Conversion failures caused by mapping and validation
Mapping interacts with the validation you already have on the target objects. These are the usual causes of a failed conversion:
- Required target field with no mapping. A custom field required on Contact has no value at creation, so the contact fails to save. Either map a lead field to it, make the lead field required, or relax the requirement.
- Validation rule on the target. Rules on Account, Contact, or Opportunity run during conversion. A rule that expects a field that the lead cannot supply will block conversion.
- Value too long for the target. Described earlier. It appears in the error message as a data-too-large problem.
- Picklist value not allowed. The lead value is not valid for a restricted target picklist.
- Record type constraints. If the default record type of the target has different picklist values than expected, mapped values can be rejected.
When a user reports "I can't convert this lead," read the full error text from the conversion screen. Salesforce names the target object and field in most of these messages, which points you straight to the mapping or validation rule to adjust.
Design guidance
A few habits keep mapping manageable:
- Map only what sales needs after conversion. Every mapping is another field to maintain on the target and another place for a validation conflict.
- Mirror field definitions. Use the same type, length, and picklist values on both sides. Then mapping is a copy, not a translation.
- Prefer contact mappings for person data. Putting individual details on the account makes them wrong when a second contact joins the company.
- Review mappings after any schema change. Deleting or retyping a field removes or invalidates its mapping.
- Test with realistic data. Convert a lead with every mapped field filled in at its maximum length. That finds truncation and picklist problems before users do.
Exercise
A custom lead field Budget__c (currency) is mapped to Opportunity.Budget__c. A rep converts a lead with the "Do not create a new opportunity" option selected. Where does the budget value end up, and can you still find it later?
Show answer
No opportunity is created, so the opportunity mapping is not applied and the value is not copied anywhere new. The value stays on the converted lead record, where you can still query it with SOQL (for example SELECT Budget__c FROM Lead WHERE IsConverted = true) or report on it.
Exercise
After conversion, the contact's Referral_Code__c is blank, but the lead had a value. You confirmed that the lead value existed before conversion. Name two things to check.
Show answer
First, open Map Lead Fields and confirm that the lead's Referral Code is mapped to the Contact field and saved. A mapping set on Account or Opportunity instead, or never saved, gives this result. Second, check that the conversion created a new contact rather than merging into an existing one, because mapped values are applied when creating records and do not overwrite an existing contact's data. Also confirm that the mapping existed when the lead was converted, since later changes do not affect past conversions.