I'm working on a Visualforce Email Template which will be sent from the parent Loan (LLC_BI__Loan__c) record in Salesforce, and I'm trying to include fields from the child Entity Involvement (LLC_BI__Legal_Entities__c) record(s).

I'm unable to pass the correct parent (Loan) Id to get the correct child records. Can anyone see where I may be going wrong ?

Thank you in advance

Component:(Name = BorrowerRecordsFromLoans)

<apex:component controller="BorrowersOnLoans" access="global">
   <apex:attribute name="currentRecordId" description="" assignTo="{!loanId}" type="Id"/>
   <apex:dataTable value="{!relatedBorrowers}" var="borrower">
      <apex:column >
         <apex:facet name="header">Borrower Name</apex:facet>

Controller: (Name = BorrowersOnLoans)

public class BorrowersOnLoans { 

    public Id loanId { get; set { loanId = value; loadChildren(); } } 
    public LLC_BI__Legal_Entities__c[] relatedBorrowers { get; set; } 

    void loadChildren() 
        List <LLC_BI__Legal_Entities__c> entList = new List<LLC_BI__Legal_Entities__c>(); 
        for(LLC_BI__Loan__c loan: [SELECT Id, (SELECT Entity_Name__c FROM LLC_BI__Legal_Entities__r ORDER BY Borrower_Number__c) FROM LLC_BI__Loan__c WHERE Id = :loanId])
            for(LLC_BI__Legal_Entities__c ent:loan.LLC_BI__Legal_Entities__r) entList.add(ent); 

Email Template:

<c:BorrowerRecordsFromLoans currentRecordId="{!relatedTo.Id}" />

In the email template make sure you define object name in relatedToType="LLC_BI__Loan__c".

<messaging:emailTemplate subject=" test" recipientType="" relatedToType="LLC_BI__Loan__c">
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.