2

I have the below VisualForce Email Template:

<messaging:emailTemplate subject="[Email] #{!relatedTo.CaseNumber} - {!relatedTo.Subject} - {!relatedTo.Contact.Name}" recipientType="User" relatedToType="Case">
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body {font-family: arial; size: 12pt;}
</style>
<body>
    <img src="https://my.salesforce.com/servlet/servlet.ImageServer?id=01561000001JYOm&oid=OBFUDCATED"/><br/>
A <b>new Email</b> was added to the case below:
<br />------------------------
<br />• Case #: {!relatedTo.CaseNumber}
<br />• Account:&nbsp;<apex:outputLink value="https://my.salesforce.com/{!relatedTo.Account}">{!relatedTo.Account.Name}</apex:outputLink>
<br />• Contact Name:&nbsp;<apex:outputLink value="https://my.salesforce.com/{!relatedTo.Contact}">{!relatedTo.Contact.Name}</apex:outputLink>
<br />• Case status: {!relatedTo.Status}
<br />• Priority: {!relatedTo.Priority}<apex:image id="theImage" value="{!relatedTo.Priority_Flags_URL__c}" width="12" height="12"/>
<br />• Link: https://my.salesforce.com/{!relatedTo.Id}
<apex:outputPanel rendered="{!relatedTo.Jira__c!=null}" >
<br />• Jira issue:&nbsp;<apex:outputLink value="https://www.atlassian.net/browse/{!relatedTo.Jira__c}">{!relatedTo.Jira__c}</apex:outputLink></apex:outputPanel>
<apex:outputPanel rendered="{!relatedTo.Git_Link__c!=null}" >
<br />• Git Link:&nbsp;<apex:outputLink value="{!relatedTo.Git_Link__c}">{!relatedTo.Git_Link__c}</apex:outputLink></apex:outputPanel>
<br />------------------------
<apex:outputPanel rendered="{!relatedTo.Last_Incoming_Email_Content__c!=null}" style="white-space:pre;">
<h3><br /><b><u>Case Last Incoming Email:</u></b></h3><br />
<apex:outputField value="{!relatedTo.Last_Incoming_Email_Content__c}" style="white-space:pre;"></apex:outputField>
</apex:outputPanel>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

This VF Email is used in a WorkFlow rule, to send and Email Alert for each new incoming Email to the case which is under his custody. The WorkFlow Rule is pretty simple, it 'listens' to the change in the Custom Field 'Last_Incoming_Email_Content__c', and fires the email notification.

The issue is that the Email notification doesn't populate the Merge Fields:

enter image description here

Below is my email client's 'original' massage:

Date: Mon, 31 Oct 2016 12:13:08 +0000 (GMT)
From: System <obfuscated>
Sender: noreply@salesforce.com
To: "obfuscated" <obfuscated>
Message-ID: <QLFAw000000000000000000000000000000000000000000000OFWV9W004MUKYztRQrCfzfyDk0URBQ@sfdc.net>
Subject: [Email] #00008640 -
  -
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_Part_16014_1675508803.1477915988038"
X-SFDC-LK: 00D61000000edsH
X-SFDC-User: 00561000001nhq1
X-Sender: postmaster@salesforce.com
X-mail_abuse_inquiries: http://www.salesforce.com/company/abuse.jsp
X-SFDC-TLS-NoRelay: 1
X-SFDC-Binding: 1WrIRBV94myi25uB
X-SFDC-EmailCategory: workflowActionAlert
X-SFDC-EntityId: obfuscated
X-SFDC-Interface: internal

------=_Part_16014_1675508803.1477915988038
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit


------=_Part_16014_1675508803.1477915988038
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit


<html>
<style type="text/css">
<!--

body {font-family: arial; size: 12pt;}

//-->
</style>
<body>
<img height="70" src="https://my.salesforce.com/servlet/servlet.ImageServer?id=01561000001JYOm&amp;oid=00D61000000edsH" width="550" /> <br />
A <b>new Email</b> was added to the case below:
<br />------------------------
<br />&#8226; Case #: 00008640
<br />&#8226; Account:&nbsp;<a href="https://my.salesforce.com/"></a>
<br />&#8226; Contact Name:&nbsp;<a href="https://my.salesforce.com/"></a>
<br />&#8226; Case status: In Progress
<br />&#8226; Priority: <img id="j_id0:emailTemplate:j_id3:j_id4:theImage" src="" height="12" width="12" />
<br />&#8226; Link: https://my.salesforce.com/500610000072FvxAAE
<br />------------------------
</body>
</html>
------=_Part_16014_1675508803.1477915988038--

In addition, when testing with the 'test and verify merge fiels' in the Email Template editor, everything looks fine:

enter image description here

Further debugging this, I found that when using a different Workflow criteria - say when the Case.Status field ISCHANGED, the Email Notification arrives with the merge fields properly.

I verified that the customer field 'Last_Incoming_Email_Content__c' has 'field level security' and 'field accessiblity' enabled and exposed. Suspecting that an order of execution might be the cause, I created the WorkFlow with Process Builder (which executes later then WF's), but issue presists.

Concluding that the WorkFlow is not the cause (after confirming it does work with a different ISCHANGED field), I am somewhat lost. If it helps, below is the WF:

enter image description here

What can be wrong which this custom field, that can cause the VF Email Template not to populate the Case Merge Fields?

5
  • what does the email look like when you do test and preview for case# 00008640 ?
    – cropredy
    Nov 1 '16 at 1:11
  • thanks for the reply. I edited the question, and added a screenshot of the properly generated test under the Email Template editor.
    – iDog
    Nov 1 '16 at 5:58
  • iDog - since relatedTo resolves to the Case, methinks the running user doesn't have access to Case.subject. What happens if you log in as the workflow's running user and go to the Case in question - is Case.Subject visible?
    – cropredy
    Nov 1 '16 at 16:34
  • Thanks cropredy. I am actually logged in as the user who 'created' thw workflow. I verified all fields security is editable. I am currently stuck. Do you have any other ideas? Thank you
    – iDog
    Nov 6 '16 at 18:07
  • Further debugging, it seems the issue is somewhere with the WF Rule / Case Custom Field. I edited the question with this new information.
    – iDog
    Nov 7 '16 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.