This is confusing me and no matter how many times I read through it I can't seem to figure it out.
I'm getting a Variable does not exist: listOfDels error on the last line of code.
Can anyone see why?
// Loads of code above this...
public void GetCustomFields() {
cf = [SELECT id, Email_to_send_confirmation_to__c, attachmentid__c, AccountID__c, courses__c, triggercheckbox__c, courses__r.Course_Notes2__c, courses__r.VenueNotesForConfirmation__c, Send_Confirmation_Automatically__c, has_confirmation_been_sent__c, courses__r.venue_address__c, courses__r.Course_Name__c, courses__r.Duration__c, courses__r.Course_Start_Date__c, courses__r.Start_Time__c, courses__r.Finish_Time__c, courses__r.Tutor2__c FROM Course_Sale__c WHERE id = :oppr];
}
public void GetDelNames(){
List<Delegate__c> dels = [SELECT id, Name, AccountID__c, Courses__c from Delegate__c WHERE AccountID__c =: cf.AccountID__c AND courses__c =: cf.Courses__c];
String listofDels;
for(Delegate__c del: dels){
if(listOfDels == null) listOfDels = del.Name;
listOfDels = listOfDels+ '<br/>'+del.Name;
}
}
public PageReference emailAtt()
{EmailTemplate template = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'Training_Confirmation_Email'];
GetCustomFields();
String subject = template.Subject;
subject = subject.replace('{!Courses__c.Course_Name__c}', cf.courses__r.Course_Name__c);
String htmlBody = template.HtmlValue;
htmlBody = htmlBody.replace('{!Courses__c.Course_Name__c}', cf.courses__r.Course_Name__c);
htmlBody = htmlBody.replace('{!Courses__c.VenueNotesForConfirmation__c}', cf.courses__r.VenueNotesForConfirmation__c);
htmlBody = htmlBody.replace('{!Courses__c.Course_Notes__c}', cf.courses__r.Course_Notes2__c);
htmlBody = htmlBody.replace('[ListOfDelegates]', GetDelNames(listOfDels));
GetDelNames
method does not take any parameter.So why are you passing one?