The most common use of merge fields is personalizing email templates. The pattern is the same across Classic and Lightning email templates.
- Open the email template editor
Setup, Communication Templates, Email Templates (Classic) or Lightning Email Templates (Lightning). Create or edit a template.
- Pick the related object
The template targets a source object (Contact, Lead, Opportunity). The merge fields available depend on this choice.
- Insert merge fields
Use the merge-field picker (typically a dropdown or toolbar button). Pick the field; the editor inserts {!FIELD_API_NAME}.
- Test with a sample record
Send a test email to yourself targeting a real record. Verify every merge field resolves correctly.
- Handle null values gracefully
For fields that might be null (middle name, suffix), wrap in IF() or BLANKVALUE() to avoid broken-looking output.
- Save and activate
Save the template. Activate it for production use. Train users to pick the right template per scenario.
The object whose fields are available as merge fields.
{!FIELD_API_NAME} or {!OBJECT.FIELD_API_NAME}.
Up to five levels through lookup relationships.
Use IF() or BLANKVALUE() to handle missing values.
- Merge fields fail silently on null. Test with real records to catch broken output.
- Cross-object traversal is capped at five levels. Beyond that, restructure the data model or use Apex.
- The merge-field syntax varies slightly across surfaces. Formulas use direct field names; templates and Visualforce use {!}; check the surface-specific documentation.
- Lightning Email Templates and Classic Email Templates use the same syntax but render differently. Test in both contexts when migrating.