You are here:
Extend Preview and Test in Marketing Cloud Next
Preview and Test is a built-in feature in Marketing Cloud Next for reviewing your message content before sending. From the Preview and Test modal, you can see how your email, SMS, or WhatsApp message appears to recipients, personalize the preview with specific segment members, and validate merge fields. The modal includes dedicated tabs for previewing rendered content and running test sends.
Required Editions
| Available in: Salesforce Enterprise and Unlimited Editions with Marketing Cloud Next Growth or Advanced Edition, and in Starter and Pro Suite Editions. Your edition determines the options that you have. |
| User Permissions Needed | |
|---|---|
| To preview and test content: | Marketing Cloud Manager permission set AND any CMS workspace contributor role |
You can extend Preview and Test by adding custom tabs to the modal. Each custom tab is powered by a Lightning Web Component (LWC) that you build and deploy to your org. The tab receives live preview data, including channel type, content, and merge field values, so you can build custom validation tools, rendering previews, or integration checks directly in the Preview and Test experience.
The extension mechanism is based on a metadata type UiPreviewMessageTabDef.
When you create and activate a UiPreviewMessageTabDef record, your custom tab
appears alongside the standard Preview and Test tabs in the modal.
-
Complete the setup for Marketing Cloud Growth or Advanced edition. For setup instructions, see the Getting Started guide.
-
Set up Salesforce Workbench.
-
Provision the Email channel. Without this,
UiPreviewMessageTabDefis not accessible.
- Understand the previewData Object
Your custom LWC receives a previewData object that contains contextual information about the message being previewed. The fields available in previewData vary by channel.
Step 1: Create and Deploy a Lightning Web Component
Create an LWC and deploy it to your org. The component provides the content that appears in your custom tab. Use the directory structure and file contents specified in the procedure.
-
Create a directory structure for your component:
lwc/ customTab/ customTab.html customTab.js customTab.js-meta.xml package.xml -
Add this markup to customTab.html:
<template> <div style="padding: 20px;"> <div>This content appears in the custom tab.</div> <div>previewData.channelType: {previewData.channelType}</div> <div>previewData.content: {previewData.content}</div> <div>previewData.contentKey: {previewData.contentKey}</div> <div>previewData.emailSubject: {previewData.emailSubject}</div> <div>previewData.emailPreheader: {previewData.emailPreheader}</div> </div> </template> -
Add this code to customTab.js:
import { LightningElement, api } from "lwc"; export default class CustomTab extends LightningElement { @api previewData; } -
Add this metadata to customTab.js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>64.0</apiVersion> <isExposed>true</isExposed> <capabilities> <capability>lightning__dynamicComponent</capability> </capabilities> </LightningComponentBundle> -
Add this content to package.xml:
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>LightningComponentBundle</name> </types> <version>64.0</version> </Package> - Deploy the component to your org.
Step 2: Create a UiPreviewMessageTabDef Entry
After you deploy your LWC, create a UiPreviewMessageTabDef record to
register your custom tab.
- In your org, click the setup icon and select Developer Console.
- In the Developer Console, click the Query Editor tab.
- At the bottom of the Query Editor, select the Use Tooling API checkbox.
-
Enter the following query, and then click Execute:
SELECT Id, DeveloperName, TabName, IsActive, SupportedChannel, LightningComponentDefId FROM UiPreviewMessageTabDef - Click Insert Row and provide values for each required field. For field descriptions, see UiPreviewMessageTabDef.
-
To get the ID of the LWC you deployed, run the following query in the Query Editor:
SELECT Id, DeveloperName, IsExposed, NamespacePrefix FROM LightningComponentBundle WHERE IsExposed = true -
Copy the
Idvalue from your component and enter it in the LightningComponentDefId field. - Click Save Rows.
After you save the UiPreviewMessageTabDef record with
IsActive set to true, your custom tab appears in the Preview
and Test modal next to the standard Preview and Test tabs. The previewData
object passed to your component updates automatically when the preview context changes, such as
when a user selects a different segment member or switches between personalized and
non-personalized views.
Step 3: Package your Extension
To distribute your Preview and Test extension through AppExchange, include both the
LightningComponentBundle and UiPreviewMessageTabDef records
in your managed package.
Users who install your package can control whether the custom tab appears in their Preview
and Test modal by modifying the IsActive field on the installed
UiPreviewMessageTabDef record.

