How to
Adding email and SMS message previews

Malcolm Jacobson
Malcolm Jacobson
  • Updated

Overview

The package ships two LWC components for rendering Message__c records and a pre-built record page that wires them together. After installation, one manual activation step is required before they become visible to users.


Included Components

Email Message Renderer (Pendula4E__emailMessageRenderer)

Renders email messages stored on Message__c records. Displays:

  • Subject, From, To, and Reply-To addresses
  • Message timestamp and delivery status badge (delivered, opened, sent, failed)
  • HTML email body with automatic XSS sanitization via lightning-formatted-rich-text
  • Toggle between HTML and plain text views

Target: lightning__RecordPage on Message__c only

SMS Message Renderer (Pendula4E__smsMessageRenderer)

Renders SMS messages stored on Message__c records. Displays:

  • Inbound and outbound messages as styled chat bubbles
  • Error details for failed message deliveries

Target: lightning__RecordPage on Message__c only


Included Record Page

Message Record Page (Message_Record_Page)

A pre-built Lightning record page for the Message__c object. Layout:

TabContentVisibility condition
Email PreviewemailMessageRendererChannel__c = 'Email'
SMS PreviewsmsMessageRendererChannel__c = 'SMS'
DetailsStandard detail panelAlways
RelatedStandard related listsAlways
ActivityActivity panel (default active)Always

The Email Preview and SMS Preview tabs are conditionally shown based on the record's Channel__c field, so only the relevant renderer is visible for a given message.


Activation Steps

1. Activate the record page in Lightning App Builder (required)

The Message_Record_Page flexipage is deployed with the package but is not automatically assigned. It must be activated manually:

  1. Go to Setup → User Interface → Lightning App Builder
  2. Locate Message Record Page in the list
  3. Click Edit, then click Activation...
  4. Choose the assignment scope:
    • Org Default — applies to all users viewing Message__c records
    • App Default — restricts to a specific Lightning app
    • App, Record Type, and Profile — for fine-grained control
  5. Save the activation

Until this step is completed, Salesforce uses the system default record page and neither renderer will appear.

2. Post-install handler (automatic — no action required)

On a fresh install, the PostInstallHandlerV2 Apex class automatically creates the default Settings__c custom settings record for the org. This requires no manual action.

3. Configure CSP Trusted Sites for external email images (conditional)

Salesforce's Content Security Policy blocks externally hosted images by default. If Message__c records contain email bodies with <img src="https://..."> URLs from external domains, those images will not render until the domains are trusted.

To enable external image display:

  1. Go to Setup → Security → CSP Trusted Sites
  2. Click New Trusted Site
  3. Enter a name and the image domain (e.g. https://images.example.com)
  4. Enable the Connect directive
  5. Save, then refresh the Message record page

Image format support:

FormatWorks without CSP config?
Base64 data URIs (data:image/png;base64,...)Yes
HTTPS URLs from a CSP Trusted SiteYes (after configuration)
External HTTPS URLs without CSP configNo
HTTP URLsNo (blocked by Salesforce)

If CSP configuration is not desired, images can be converted to base64 data URIs in Apex before the Message__c record is created or updated, which requires no CSP changes.


Adding Renderers to a Custom Record Page

If the included Message_Record_Page is not used, both components can be placed manually on any Message__c record page via Lightning App Builder:

  1. Open the target record page in Setup → Lightning App Builder
  2. In the component panel, search for Email Message Renderer or SMS Message Renderer (under the Pendula4E namespace)
  3. Drag the component to the desired region
  4. Optionally add a visibility rule on Channel__c to show only the relevant renderer
  5. Save and activate the page