We have a S-control button which sys SendAttendancelist. The S-control calls the apex class Classobj in that we have a email that is sent out from apex while executing it sends out email with few details.
The requirement here is to display a additional Date time field in the email. However the User request it not to show time it should show only the Date. I tried to add the field in the Code but this was displaying in reverse.
The field that we added is Current Rivision- It is a Date field.
Please find the code below.
WebService static Id[] sendAttendanceList_TIS(Id ClassId) {
//Modified by [email protected] to include more venue and class material details
Class__c classObj = [Select Trainer_1__c, Trainer_1__r.Id, Trainer_1__r.Email,Trainer_1__r.EmailBouncedDate,
Trainer_1__r.EmailBouncedReason,Trainer2__c, Trainer2__r.Id, Trainer2__r.Email, Trainer2__r.EmailBouncedDate,
Trainer2__r.EmailBouncedReason, Trainer_2__c, Trainer_2__r.Id, Trainer_2__r.EmailBouncedDate,
Trainer_2__r.EmailBouncedReason,Trainer_2__r.Email, Id, Venue__r.Id, Venue__r.Name, Venue__r.Business_Street__c,
Venue__r.Business_City__c, Venue__r.Business_State_Province__c, Venue__r.Business_Zip_Postal_Code__c,
Venue__r.Business_Country__c, Venue__r.Website, Venue__r.Phone, Venue__r.Internet_Email__c, Venue__r.Comments__c,
Course_Name__r.Name, Class_Location__c, Class_End_Date__c, Class_Begin_Date__c, Num_in_Stock__c,
Num_Standards_Out__c, Num_Standards_In__c, Num_Material_Printed__c, Num_Material_Ordered__c, Job_Reference__c,
Date_Material_Sent__c, Date_Material_Ordered__c, Comments_Materials__c, Boxes__c
From Class__c where Id =:ClassId];
//Modified by [email protected], validation of the bounced emails
//Modified by [email protected] on 12/02/2009 to incorporate the Primary_Venue_Contact__c functionality
Contact[] conObj = [Select Id, Email, AccountId,EmailBouncedDate,EmailBouncedReason From Contact where AccountId =:classObj.Venue__r.Id and Primary_Venue_Contact__c = true];
//Contact[] conObj = [Select Id, Email, AccountId From Contact where AccountId =:classObj.Venue__r.Id];
//Query course field to add them in the Email template.
Course__c crs = [select id,Current_Revision__c from Course__c limit 1];
//if (classObj.Trainer_1__r.Email != null || classObj.Trainer_2__r.Email != null || conObj.Email != null) {
String jobTitle;
String email;
String phone;
String mobile;
String dietaryNeeds;
String accessNeeds;
String HTMLBody;
List<Id> RegIds = new List<Id>();
RegIds = getConfirmedIds(ClassId);
HTMLBody = 'Hi,<br><br>';
HTMLBody = HTMLBody + 'Please find attached the Attendance List for SAI Global\'s course.<br><br>';
HTMLBody = HTMLBody + 'Please print off a copy and hand to the Trainer on the morning of the course.<br><br>';
HTMLBody = HTMLBody + 'If you have any questions please don\'t hesitate to contact our Customer Service Team on 1-800-374-3818.<br><br>';
HTMLBody = HTMLBody + 'Kind Regards,<br>Training and Improvement Solutions<br><br>';
HTMLBody = HTMLBody + '<b><u>Course Information</u></b><br><br>';
if(classObj.Class_End_Date__c != null){
HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - ' + classObj.Class_End_Date__c.day() + '/' + classObj.Class_End_Date__c.month() + '/' + classObj.Class_End_Date__c.year() + '<br>';
} else {
HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - N/A<br>';
}
HTMLBody = HTMLBody + 'Class Location: ' + classObj.Class_Location__c + '<br><br>';
HTMLBody = HTMLBody + '<b><u>Venue Details</u></b><br><br>';
How ever when we receive the email we found some misformats. Course Name: CURRENT REVISION: Class Dates: Class Location:
Course Information
Course Name: ISO 9001:2015 Lead Auditor Class Dates: 4/12/2018 - 7/12/2018 Current Revision:2018-04-25 00:00:00 Class Location: Toronto - ON - CANADA
Please find the below image this is how the current revision field displayed in salesforce.
Please advise how to correct this to show only the date that should be in MM/DD/YYY as per in salesforce screenshot. But in the above bold text the date format is displaying differently from the way is displays in salesforce.
Thanks for the help.