0

I have a Visualforce email template. When i check it with "Send Test and verify Merge fields" then it is working perfectly. However, when it passes through an email alert then only few fields' values get in template.

enter image description here

<messaging:emailTemplate subject="Please Check Out Details of Newly Added Ecommerce Order" recipientType="User" relatedToType="ccrz__E_Order__c" >

 
<messaging:htmlEmailBody >
<html>

<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
  background-color: #D9D9D9;
}

</style>
</head>
<Body>

<div align="Center">
<apex:image id="Logo" value="https://us-azbil--c.documentforce.com/servlet/servlet.ImageServer?id=01541000001w9ZE&oid=00D41000002vT6u&lastMod=1489696652000"/> </div>

<hr></hr>

<h2> New Ecommerce <a href="{!LEFT($Api.Partner_Server_URL_280, FIND(".com/",$Api.Partner_Server_URL_280)+3)}/{!relatedTo.Id}"> Order </a> Information : </h2>

<table style="width:100%">

<Th><h2> Account Information</h2></th> <th><h2>Buyer Information</h2></th>

<tr><td>Account Name:&nbsp; <apex:outputField value="{!relatedTo.ccrz__Account__r.name}" />  &nbsp;  &nbsp; <a href="{!LEFT($Api.Partner_Server_URL_280, FIND(".com/",$Api.Partner_Server_URL_280)+3)}/{!relatedTo.ccrz__Account__c}"> (VIEW) </a> </td>

<td>First Name:  <apex:outputField value="{!relatedTo.ccrz__BuyerFirstName__c}"/></td></tr>
<tr><td>Tax ID: <apex:outputField value="{!relatedTo.TAX_ID__c}"/> </td>
<td>Last Name:  <apex:outputField value="{!relatedTo.ccrz__BuyerLastName__c}"/> </td></tr>


<tr><td>Tax Exempt Flag: {!if(relatedTo.ccrz__TaxExemptFlag__c==TRUE,"Yes","No")} </td>
<td>Mobile Number: <apex:outputField value="{!relatedTo.ccrz__BuyerMobilePhone__c}"/> </td></tr>


<tr><td> VerifyExemptionFlag: {!if(relatedTo.ccrz__VerifyExemptionFlag__c==TRUE,"Yes","No")} </td> 
<td>Email: <apex:outputField value="{!relatedTo.ccrz__BuyerEmail__c}"/> </td></tr>


<apex:repeat var="Ai" value="{!relatedTo.ccrz__Account__r}">
            <tr>
            
            <td  colspan="2">Account Associated Contact Numer : <apex:outputField value="{!Ai.Phone}"/></td>
                            
            </tr>
</apex:repeat>

</table>
<br/>
 <table style="width:100%">
<Th colspan="4"><h2> Order Item Information</h2></th>

<apex:repeat var="li" value="{!relatedTo.ccrz__E_OrderItems__r}">
<tr>
<th> Product Name</th> <th> Price </th> <th> Quantity </th> <th> Total </th></tr>

            <tr>
            
            <td style="text-align:center;"><apex:outputField value="{!li.ccrz__Product_Name__c}"/></td>
            <td style="text-align:center;"><apex:outputField value="{!li.ccrz__Price__c}"/></td>
            <td style="text-align:center;"><apex:outputField value="{!li.ccrz__Quantity__c}"/></td>
             <td style="text-align:center;"><apex:outputField value="{!li.ccrz__ItemTotal__c}"/></td>
             
                
            </tr>

 </apex:repeat>




</table>
<br/>
<table style="width:100%">

<Th><h2> Order Information</h2></th> <th><h2>Amount/Tax Information</h2></th>

<tr><td>Oder ID: <apex:outputField value="{!relatedTo.ccrz__OrderId__c}"/></td>
<td>Total Amount  <apex:outputField value="{!relatedTo.ccrz__TotalAmount__c}"/></td></tr>

<tr><td>Order Name: <apex:outputField value="{!relatedTo.ccrz__Name__c}"/></td>
<td>Total Discount: <apex:outputField value="{!relatedTo.ccrz__TotalDiscount__c}"/></td></tr>


<tr><td>Order Status:  <apex:outputField value="{!relatedTo.ccrz__OrderStatus__c}"/></td>
<td>Tax Amount:  <apex:outputField value="{!relatedTo.ccrz__TaxAmount__c}"/></td></tr>


<tr><td>Split Parent Order:<apex:outputField value="{!relatedTo.ccrz__SplitParentOrder__c }"/></td>
<td>Tax SubTotal Amount:  <apex:outputField value="{!relatedTo.ccrz__TaxSubTotalAmount__c}"/></td></tr>


<tr><td>PO Number: <apex:outputField value="{!relatedTo.ccrz__PONumber__c}"/></td>
<td>Sub Total Amount:  <apex:outputField value="{!relatedTo.ccrz__SubtotalAmount__c}"/></td></tr>



<tr><td>Ship To:  <a href="{!LEFT($Api.Partner_Server_URL_280, FIND(".com/",$Api.Partner_Server_URL_280)+3)}/{!relatedTo.ccrz__ShipTo__c}">Ship To Adderess </a> </td>
 
<td>Bill To: <a href="{!LEFT($Api.Partner_Server_URL_280, FIND(".com/",$Api.Partner_Server_URL_280)+3)}/{!relatedTo.ccrz__BillTo__c}">Bill To Adderess</a> </td></tr>

</table>

<br/>

<table style="width:100%">

<Th><h2> Shipping Information</h2></th> 

<tr><td>Ship Amount: <apex:outputField value="{!relatedTo.ccrz__ShipAmount__c}"/></td></tr>
<tr><td>Ship Complete: {!if(relatedTo.ccrz__ShipComplete__c==TRUE,"Yes","No")} </td></tr>

<tr><td>Ship Structure: <apex:outputField value="{!relatedTo.ccrz__ShipStructure__c}"/></td></tr>
<tr><td>Ship Discount Amount: <apex:outputField value="{!relatedTo.ccrz__ShipDiscountAmount__c}"/></td></tr>
<tr><td>Ship Method: <apex:outputField value="{!relatedTo.ccrz__ShipMethod__c}"/></td></tr>

</table>

  <br/>

<table style="width:100%">
<Th><h2> Other Information</h2></th>

<tr><td>Note: <apex:outputField value="{!relatedTo.ccrz__Note__c}"/></td></tr>
<tr><td>Request Date:  <apex:outputField value="{!relatedTo.ccrz__RequestDate__c}"/></td></tr>
</table>  
   

 <hr></hr>
<div align="Center">
<apex:image id="LetterheadLogo" value="https://us-azbil--c.documentforce.com/servlet/servlet.ImageServer?id=01541000002zp22&oid=00D41000002vT6u&lastMod=1522786514000"/> </div>

</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
2
  • Have you checked the field-level security for all of these fields?
    – David Reed
    Aug 17, 2020 at 17:29
  • Yes, some fields are ready only and visible to only System Admin.
    – sarita
    Aug 17, 2020 at 17:41

1 Answer 1

1

Per your comment:

... some fields are read[] only and visible to only System Admin

Visualforce enforces Field-Level Security. If you wish this data to be rendered into the template, you must expose them to the running user when the template is rendered.

While it is possible to bypass Visualforce's security enforcement by using Apex to acquire the data instead of directly referencing fields, this is not recommended because it does an end-run around the Salesforce security model.

1
  • Yes, issue was with field level security and as soon as I make them visible everything started working as expected. Thank you so much.....
    – sarita
    Aug 28, 2020 at 15:54

You must log in to answer this question.

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