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
Emmanuel CoronaEmmanuel Corona 

Email template with two objects

Greetings!

 

I have an email template for a custom object and is relatedToType="SLAyEdif__c" in this object I have a lookup field for the opp, so how can i display the product related list here too???

 

Thank you so much

Emmanuel CoronaEmmanuel Corona

Here is my code

 

<messaging:emailTemplate subject="Alerta Harmoni:Solicitud de Aprobación SLA - {!relatedTo.Oportunidad__r.Name}" recipientType="User"
relatedToType="SLAyEdif__c"

replyTo="ecorona@mcmtelecom.com.mx">
<messaging:htmlEmailBody >
<html>

<body>
<table width="800" border="0" cellspacing="1" cellpadding="1">
<tr>
<td align="right" valign="middle"><img src="https://c.cs16.content.force.com/servlet/servlet.ImageServer?id=015f00000000W72&oid=00Df00000004XvE" alt="MCM Telecom"

style="display:block;width:130px;"></img></td>
</tr>
<tr>
<td style="background-color: #555; font-family: Arial; font-size: 14px; color: #FFF; text-align: center; font-weight: bold;">Solicitud de Aprobación SLA - {!relatedTo.Oportunidad__r.Name}</td>
</tr>
<tr>
<td><table width="796" border="0" cellspacing="2" cellpadding="1">
<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;" width="40%">Nombre de la Oportunidad</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">{!relatedTo.Oportunidad__r.Name}</td>
</tr>


<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;">Solicitante</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">{!relatedTo.Owner.name}</td>
</tr>


<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;">Tipo de Oportunidad</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">{!relatedTo.Oportunidad__r.Type}</td>
</tr>
<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;">Etapa de la Oportunidad</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">{!relatedTo.Oportunidad__r.Stagename}</td>
</tr>
<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;">Importe Meta y Previsión</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">{!relatedTo.Oportunidad__r.Amount}</td>
</tr>
<tr>
<td Style="background-color: #888; font-family: Arial; font-size: 12px; color: #FFF; text-align: center; font-weight: bold;">Importe de la Oportunidad</td>
<td Style="background-color: #EEE; font-family: Arial; font-size: 14px; color: #000; text-align: center;">${!relatedTo.Oportunidad__r.importe_total__c}</td>
</tr>
<tr>
<td>
<apex:outputLink value="https://na2.salesforce.com/{!relatedTo.Id}">
Solicitud de SLA
</apex:outputLink>
</td>
<td>
<apex:outputLink value="https://na2.salesforce.com/{!relatedTo.Oportunidad__r.id}">
Oportunidad
</apex:outputLink>
</td>
</tr>
</table>
</td>

</tr>
</table>
<table width="796" border="0" cellspacing="1" cellpadding="1">
<tr>
<th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Edificio (Punta de Entrega)</th><th style="background-color: #CCC;

font: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Clasificación Comercial</th>
<th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">SLA que Aplica</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.puntas__r}">
<tr>
<td style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cx.Edificio__c }" /></td>
<td style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cx.Clasificaci_n_Comercial__c }" /></td>
<td style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cx.SLA__c }" /></td>


</tr>
</apex:repeat>
</table>

<tr>
<td>
<table width="796" border="0" cellspacing="1" cellpadding="1">
<tr>
<th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Producto</th><th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Cantidad</th>
<th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Precio</th><th style="background-color: #CCC; font-family: Arial; font-size: 12px; color: #000; text-align: center; font-weight: bold;">Total</th>
</tr>
<apex:repeat var="cr" value="{!relatedTo.Oportunidad__r.OpportunityLineItems}">
<tr>
<td Style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cr.PricebookEntry.name }" /></td>
<td Style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cr.Quantity }" /></td>
<td Style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cr.Precio_de_venta_plantilla__c}" /></td>
<td Style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cr.Precio_total_plantilla__c}" /></td>
</tr>
</apex:repeat>
</table>
</td>
</tr>






<td>
<tr>
</tr>
<table width="796" border="0" cellspacing="1" cellpadding="1">

<apex:repeat var="cx" value="{!relatedTo.ProcessSteps}">
<tr>
<td style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cx.CreatedBy.name}" /></td>
<td style="background-color: #FFF; font-family: Arial; font-size: 14px; color: #000; text-align: center;"><apex:outputField value="{!cx.Comments}" /></td>
</tr>
</apex:repeat>
</table>
</td>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

I get an error on: Error: Aggregate Relationship is used in an unsupported complex expression containing 'Oportunidad__r.opportunitylineitems'

 

Thank you so much!!!

Avidev9Avidev9
No formatting hmm ?
Have you really written this code ?
Where is your controller ?