0

Hi I'm pretty new to the salesforce platform so any help would be appreciated. I am trying to create custom email template components, but when I clear out any data from a custom field it wont save the template.

  • Step 1: If I add the new component to the email template and save (without adding anything to the custom fields) it saves fine
  • Step 2: Then I add content to one of the custom fields again saves fine
  • Step 3: If I then clear out the data I just added in the previous step, so that its back to step 1 and save I get the following error

enter image description here

None of the fields I've added are required as I can save on step 1 without entering anything.

I'm trying to achieve a section that allows the user to add a note to an email and if they don't add anything it just displays the default information, I am also expecting the templates to be cloned so it might be a case where the original email has text but the cloned email doesn't require custom text so they need to be able to remove it and save the email template.

HTML markup

<template>
    <div>
        <table>
            <tbody>
            <tr>
                <td></td>
                    <template if:true={preambleLeft}>
                        <div>{preambleLeft}</div>
                    </template>
                    <template if:false={preambleLeft}>
                        <div>for internal only</div>
                    </template>
                </td>
                <template if:true={htmlVersionUrl}>
                <td >
                    <template if:true={preambleRight}>
                        <div >{preambleRight} <a href={htmlVersionUrl} target="_blank">{preambleLinkText}</a>.</div>
                    </template>
                    <template if:false={preambleRight}>
                        <div >to view the web version, click <a href={htmlVersionUrl} target="_blank">here</a>.</div>
                    </template>
                </td>
                </template>
            </tr>
            </tbody>
        </table>
    </div>
</template>

JS

import { LightningElement, api } from 'lwc';

export default class GuidedManualEntry extends LightningElement {
    @api
    preambleLeft=""
    @api
    preambleRight=""
    @api
    preambleLinkText=""
    @api
    htmlVersionUrl=""
}

Meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Preamble</masterLabel>
    <targets>
        <target>lightningStatic__Email</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightningStatic__Email">
            <property
                label="Preamble Text Left"
                name="preambleLeft"
                type="String"
                description="Enter the text you want to output on the top left"
                required="false" />
            <property
                label="Preamble Text Right"
                name="preambleRight"
                type="String"
                description="Enter the text you want to output on the top right"
                required="false" />
            <property
                label="Preamble Link Text"
                name="preambleLinkText"
                type="String"
                description="Enter the text you want to output for the link"
                required="false" />            
            <property 
                label="HTML Email Version URL" 
                name="htmlVersionUrl"
                type="String"
                placeholder="https://"
                description="Enter the url of the HTML version of this email ensure secure URL starting with https://"
                required="false" />
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

1 Answer 1

0

UPDATE June 2024: The method still works, but now the field has to be filled with a space in the template for saving to take place.

I have exactly the same problem: when the text field is empty, Email Template Builder doesn't set the value to null or empty, but omits it when saving, resulting in a serialization internal error (Error on parameter nodes: java://visualeditor.service.BuilderModelSerializable).

The workaround I've found is to add a space to the string when saving, and to make a template if:true={isLinkDisplayed} with :

get isLinkDisplayed() {
    return !!this.htmlVersionUrl && this.htmlVersionUrl.trim().length > 0;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .