function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Debbie ChrysochouDebbie Chrysochou 

Total Price( from order product object) into VF email template

I have created an email to merge the order product fields into it. A snippet of my Code is :
<tr>
                    <td style="background-color: #BA4697; color: #FFFFFF">
                        <b>Item/Package</b>
                    </td>
                    <td style="background-color: #BA4697; color: #FFFFFF">
                        <b>Amount</b>
                    </td>
                    <td style="background-color: #BA4697; color: #FFFFFF">
                        <b>Quantity</b>
                    </td>
                    <td style="background-color: #BA4697; color: #FFFFFF">
                        <b>Total</b>
                    </td>
                    
                </tr>
                       <apex:repeat value="{!relatedTo.OrderItems}" var="lineItem">
                        <tr>
                            <td>
                                 {!lineItem.PricebookEntry.Product2.Name}
                             </td>
                             <td>
                                {!lineItem.UnitPrice}
                            </td>
                             <td>
                                 {!lineItem.Quantity__c}
                            </td>
                            <td>
                                 {!lineItem.TotalPrice}
                            </td>
                        </tr>
                </apex:repeat>


I do get all the fields in order but do get an error for the Total price.
Error: Invalid field TotalPrice for SObject OrderItem

Any ideas?? ( the thing is that unit price and total price are under the object order item as I can understand. So its not a sum field that needs to sum up inside the email but pre-exists when you add the product and select the quantity and goes on the order products related list in Order)
Best Answer chosen by Debbie Chrysochou
Debbie ChrysochouDebbie Chrysochou
Hello Fred. As I read on the manual Salesforce defines Unit Price as a standard field but even if Total Price is listed under the standard fields of Order Product, salesforce is not defining it. So what I've done is to create a custom formula wise field that multiplies quantity with unit price. It works fine now!! 

Total_Price__c = Quantity*Unit Price

All Answers

Frédéric TrébuchetFrédéric Trébuchet
Hi,

On my org I can't unit price and total price fields under Order object.
I suppose they are custom fields and if so, you have to change API name to UnitPrice__c and TotalPrice__c respectivly.

Hope this helps,
Fred
Debbie ChrysochouDebbie Chrysochou
Hello Fred. As I read on the manual Salesforce defines Unit Price as a standard field but even if Total Price is listed under the standard fields of Order Product, salesforce is not defining it. So what I've done is to create a custom formula wise field that multiplies quantity with unit price. It works fine now!! 

Total_Price__c = Quantity*Unit Price
This was selected as the best answer
Frédéric TrébuchetFrédéric Trébuchet
You're right, these fields are under 'Order Product', not 'Order'.
You should mark this question as 'Solved'