• Yukinon
  • NEWBIE
  • 60 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 1
    Replies
I want to show different data in the email template depending on the opportunity I'm using it on. Is it possible?

For Example:
When I'm on this opportunity record then it should only show the first product on the email template since it's the only related product on this record.
User-added image

Controller:
public class ActiveOpportunityLineItems {
    private final List<OpportunityLineItem> lineItems;
    	
    public ActiveOpportunityLineItems(){
       lineItems = [SELECT ProductCode,UnitPrice,Description,Status__c From OpportunityLineItem WHERE Status__c = 'ACTIVE';
    }
    
    public List<OpportunityLineItem> getActiveOpportunityLineItems(){
        return lineItems;
    }
    
}

Component
<apex:component controller="ActiveOpportunityLineItems" access="global">
	<apex:dataTable border="below" value="{!ActiveOpportunityLineItems}" var="active_opp" width="75%" style="text-align:center;" >
        <apex:column value="{!active_opp.ProductCode}" headerValue="Product Name" />
	    <apex:column value="{!active_opp.Description}" headerValue="Line Description"/>
         <apex:column value="{!active_opp.UnitPrice}" headerValue="Sales Price"/>
         <apex:column value="{!active_opp.Status__c}" headerValue="Status"/>
	</apex:dataTable>
</apex:component>