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
Wayne_ClarkWayne_Clark 

Apex Controller - Visualforce Email template - SOSL - Multiple Objects

Hello,

 

I'm trying to bring over a list of line items (Payor_Line_Item__c) to an object through lookup fields. 

 

The Pricing_PDF__c object contains a lookup field (Customer_Pricing__c) to the Customer_Price__c object, which is the Master/Detail to the Payor_Line_items__c.  The field on the Payor_Line_items__c that also contains the Customer Price Id is (Payor_Pricing_Number__c). 

 

Since these two object contain similar Id's, I should be able to list the line items on the PDF's....right?   Below is what I have so far and I marked in red what I want the code to say, but am not sure how to code it.

 

Any idea on how I can bring over the line items to the email teamplate? 

 

Thanks in advance!

 

 

Visualforce Email controller component:

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Pricing_PDF__c" subject="KCC Sales Order {!relatedTo.name}" >


<messaging:htmlEmailBody >

<br>
Dear {!recipient.name},</br>

<p>Thank you for your order.</p>

<p>Attached is Sales Order #<apex:outputText value="{!relatedTo.Name}"/>, please review,
sign and fax back at your earliest convenience. </p>

 

<apex:component controller="SalesOrderEmailExtension" access="global">
    <apex:dataTable value="{!lineitem}" var="line">


        <apex:column >
            <apex:facet name="header">Customer Pricing Number</apex:facet>
            {!line.Name}
        </apex:column>


            <apex:column >
            <apex:facet name="header">Product</apex:facet>
            {!line.Product__c}
        </apex:column>


    </apex:dataTable>
</apex:component>

</messaging:htmlEmailBody>

 

Controller:

 

public with sharing class SalesOrderEmailExtension {

    public SalesOrderEmailExtension() {

    }

    private final List<Payor_Line_Item__c> lineitem;
    private final List<Customer_Price__c> price;
    private final List<Pricing_PDF__c> pdf;

    
public SalesOrderEmailExtension(ApexPages.StandardController controller)
        {        
        lineitem = [select id, Name, Payor_Pricing_Number__r.Id, Product__c, Quantity__c, Total_Price__c
        from Payor_Line_Item__c  where Customer_Pricing__r.Id = Pricing_PDF__r.Customer_Pricing__r.Id];
        }


public List<Payor_Line_Item__c> getlineitem() {
            return lineitem;
      }
      

}