You need to sign in to do that
Don't have an account?
Sabrent
Select Email Template and edit the contents---- my attempt so far (Apex Class/VFP )
I have created a picklist that displays all Email Templates in a Folder called Change Request.
Based on the selected Template from the picklist, i want to edit the contents of the template before Sending the email out.
When I select a Template I only see a Rich text editor.
Can someone please point out what I am missing? Thanks!!
public class EmailTemplateSelector { public String selectedTemplateId { public get; public set; } public String templateBody { public get; public set; } set <string> templatename = new set <string>(); public List<SelectOption> getTemplateFolderOptions() { List<Folder> Folders = [Select Id, Name From Folder Where Type = 'Email']; system.debug(Folders.size()); Set<ID> FolderIds = new Set<ID>(); for(Folder f:Folders){ FolderIds.add(f.Id); } system.debug(FolderIds.size()); List<SelectOption> options = new List<SelectOption>(); List<EmailTemplate> Templates = [Select Id, Name, IsActive, Folder.Name From EmailTemplate Where IsActive = true And Folder.Id IN :FolderIds AND Folder.Name =: 'Change Request' ]; System.debug('***Size is***' +Templates.size()); for (EmailTemplate ET : Templates){ options.add(new SelectOption(ET.Id,ET.Name)); templatename.add(ET.Name); } return options; } public void showContent(){ // query the template body based on selected template EmailTemplate t = [select Id,body from EmailTemplate where name =: templatename ]; // Assign template body to "templateBody" templatebody =t.body; } } ========VisualForce Page=========== <apex:page controller="EmailTemplateSelecto> <apex:form > <apex:actionFunction name="displayTemplate" action ="{!showContent}" reRender="pan"/> <apex:selectList value="{!selectedTemplateId}" size="1"> <apex:selectOptions value="{!TemplateFolderOptions}" /> </apex:selectList> <apex:outputPanel id="pan"> <apex:inputTextArea value="{!templatebody}" richText="true"/> </apex:outputPanel> </apex:form> </apex:page>
take a look at apex:actionSupport. then use it with selectList and on change rerender text area.