I need to find a way where it displays just one value in the below email template
Apex Controller:
public class ContactController
{
public id contactId {get;set;}
public List<Lead> getleads2()
{
public List<Lead> getleads()
{
List<Lead> leadList = new List<Lead>();
leadList = [
SELECT Loan_Number__c
,Loan_Number__c
, Banker__c
, banker__r.Name
, App_Date__c
, QL_banker__r.email
FROM Lead
WHERE Banker__c =:contactId Limit 10];
return leadList ;
}
List<Lead> leadList2 = new List<Lead>();
leadList2 = [SELECT banker__r.FirstName FROM Lead WHERE Banker__c =:contactId Limit 1];
return leadList2 ;
}
}
Visualforce Componet:
<apex:component controller="ContactController" access="global">
<apex:attribute name="ContId" type="id" description="Id of the contact"
assignTo="{!contactId }"/>
<html> <apex:repeat value="{!leads}" var="l">
<H2>HELLO {!l.bank__r.Name}</H2>
</apex:repeat>
</html>
</apex:component>
My Output in Visualforce Email Template is
HELLO Aaron Shook
HELLO Aaron Shook
HELLO Aaron Shook
I just need it to display once. I know i am running into this because I am using the List in class and repeat in VF, but I want to know if there is any other way to achieve this. Need the solution ASAP.
Thanks in advance.
Test Class:
@isTest()
private class test_ContactController {
static testMethod void mainTest() {
Contact c = new contact();
c.firstname = 'test';
c.LastName = 'last';
c.email = '[email protected]';
c.recordtypeid = '0120d0000001Gvo';
insert c;
Lead l = new Lead();
l.lastName = 'asd';
l.banker__c = c.id;
l.recordtypeid = '0120d0000001GzR';
insert l;
ContactController classObject = new ContactController();
List<Lead> leadlist = new List<Lead>();
List<Lead> leadList3 = new List<Lead>();
classObject.contactId = c.Id;
leadlist= classObject.getleads();
ContactController.recordWrapper wrapper = new ContactController.recordWrapper(c.Id); //Just passed contact parameter in this contructor
wrapper.ContactName = 'test';
System.assertNotEquals(0, leadlist.size());
//System.assertNotEquals(1, recordWrapper.size());
}
}