Skip to main content
Amit Sharma (Trantorinc) 님이 #Visualforce에 질문했습니다
Created a custom vf page for the end user to update the email template and send an email but the htmlvalue of the html email template is causing an issue with the save.

Page 

Unable to save htmlValue of html email template via apex vf controller

Error after I click Save

User-added image

Code:

VF:

<apex:pageBlock title="Email Body" >

            <apex:inputTextarea value="{!emailBody}" richText="true" style="min-width:100%;height:350px;width:120px" > 

            </apex:inputTextarea>

        </apex:pageBlock>

Apex:

EmailTemplate emailTemp = [Select id,subject,body,HtmlValue from EmailTemplate where name = :templateName limit 1]; 

            emailTemp.Subject = subject;

            emailTemp.HtmlValue = String.ValueOf(body);

            system.debug('body:'+body);

            update emailTemp;
답변 1개
  1. 2019년 11월 4일 오전 10:48
    Error:

    Update failed. First exception on row 0 with id 00X1U000000RbpLUAS; first error: FIELD_INTEGRITY_EXCEPTION, The HTML Email Content contains improperly formatted merge fields. Please check the format of all the merge fields to ensure they start with {! and end with }.: [HtmlValue]

    Error is in expression '{!saveTemplate}' in component <apex:commandButton> 
0/9000